Reputation: 383
I have two ASTableNode
1. Notifications tabelNode
2.Comments tabelNode
now I want to make a segment controller as a sticky header on the table, when I click on Notifications segment the notificationTable should appear and when I click on comments segment the commentsTable should appear as in this image WatchList and Following Segment,How can I achieve this any help appreciated.
Upvotes: 2
Views: 439
Reputation: 494
A bit late to the party, but hope this helps. It's not difficult at all to use native views for displaying nodes. Here is how it's done for the segment control:
///Keep a reference to the segment control
private var segmentedView: UISegmentedControl?
///This node will contain the segment control
private lazy var segmentedNode: ASDisplayNode = {
///The node is initialized with a view block that initializes the segment
return ASDisplayNode(viewBlock: { () -> UIView in
self.segmentedView = UISegmentedControl(items: ["Watchlist", "Following"])
///Select Watchlist maybe? Your call.
self.segmentedView.selectedSegmentIndex = 1
///Configure additional appearance of the segment control
return self.segmentedView
})
}()
After that, do any node operations you want (i.e. include in stack view, set style) on the node, and any segmented control operations you want (i.e. value changed selector) on the native control.
Upvotes: 1