如何在swift 3中使用AsyncDisplayKit创建一个段控制器

问题描述 投票:2回答:1

我有两个ASTableNode 1. Notifications tabelNode 2.Comments tabelNode现在我想将一个段控制器作为表上的粘性标题,当我点击通知段时,应该出现notificationTable,当我点击评论段时,commentsTable应该显示为在此imageenter image description here观察列表和以下细分,我怎样才能实现这一点任何帮助赞赏。

ios swift3 asyncdisplaykit
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
    })
}()

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

© www.soinside.com 2019 - 2024. All rights reserved.