ios - 如何在 swift 3 中使用 AsyncDisplayKit 制作段 Controller

标签 ios swift3 asyncdisplaykit

我有两个 ASTableNode 1.通知tabelNode 2.评论tabelNode 现在我想将段 Controller 作为表上的粘性标题,当我单击通知段时,通知表应该出现,当我单击评论段时,评论表应该如图所示显示 enter image description here WatchList 和 Following Segment,我怎样才能做到这一点,感谢任何帮助。

最佳答案

聚会有点晚了,但希望这对您有所帮助。使用 native View 来显示节点一点也不难。 以下是段控制的实现方式:

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

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

关于ios - 如何在 swift 3 中使用 AsyncDisplayKit 制作段 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47216971/

相关文章:

ios - 导航错误swift 3

ios - 重新加载 tableview 时发生断言失败?

ios - ASyncDisplayKit (Texture) - 调整可见节点的大小

swift - 如何使用 RxSwift 实现 ASButtonNode 目标

ios - 主队列上的调度屏障

ios - 无法从 xib 调用 Storyboard

ios - 部署到 Apple 商务管理客户

Swift DidSelectRowAt 没有开火

iOS - UIButton 图像不符合预期

ios - 如何保存图像