AsyncDisplayKit ASButtonNode如何设置buttonType

时间:2017-07-07 02:39:39

标签: ios swift asyncdisplaykit

我想得到一个与UIButton相同的buttonNode(类型:.system)。 如何设置

1 个答案:

答案 0 :(得分:2)

    let buttonNode = ASDisplayNode { () -> UIButton in
        let button = UIButton(type: .system)
        button.backgroundColor = UIColor.white
        button.cornerRadius = 4
        button.setTitleColor(UIColor.red, for: .normal)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 17)
        return button
    }

    if let button = buttonNode.view as? UIButton {
        button.setTitle("qqq", for: .normal)
        button.addTarget(self, action: #selector(tapAction), for: .touchUpInside)
    }