2

我有两个 ASTableNode 1. Notifications tabelNode 2.Comments tabelNode 现在我想将段控制器作为表格上的粘性标题,当我单击 Notifications 段时,notificationTable 应该出现,当我单击评论段时,commentsTable 应该显示为在这张图片的在此处输入图像描述WatchList 和Following Segment 中,我怎样才能实现这一点,感谢您的帮助。

4

1 回答 1

1

聚会有点晚了,但希望这会有所帮助。使用原生视图显示节点一点也不难。以下是分段控制的完成方式:

///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
    })
}()

之后,在节点上执行您想要的任何节点操作(即包括在堆栈视图中,设置样式),以及在本机控件上执行您想要的任何分段控件操作(即值更改选择器)。

于 2018-01-11T18:43:01.370 回答