ios - 如何在 AsyncDisplayKit ASButtonNode 上设置标题?

标签 ios swift asyncdisplaykit

我可以这样设置正常状态的标题:

let buttonTitle = NSAttributedString(string: "Book", attributes: attributes)
buttonNode.titleNode.attributedText = buttonTitle

但是,这不会设置按钮禁用状态的标题。为了实现这一点,我尝试添加以下内容:

buttonNode.setAttributedTitle(buttonTitle, for: .disabled)

但是,这会删除正常状态的图 block 。没有 ASControlState.normal

如何将按钮的标题设置为在所有状态下都相同?

最佳答案

可以通过为 ASControlState 设置空数组来为所有状态设置按钮标题:

let buttonTitle = NSAttributedString(string: "Book", attributes: attributes)
buttonNode.setAttributedTitle(buttonTitle, for: [])

关于ios - 如何在 AsyncDisplayKit ASButtonNode 上设置标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41682384/

相关文章:

ios - 如何在旋转时定义 CollectionView 的大小

ios - 如何在 swift 的 Alamofire Post 请求中将 token 字符串(jwt)作为 Cookie 发送?

ios - 具有动态宽度的水平布局以填充父级

ios - 在 ASTextNode 周围添加填充

ios - 在 Xcode 4.3 上为模拟器构建 OpenSSL 失败

ios - 如何异步更新 UITableView?

ios - cellForItemAtIndexPath : 中不是唯一的单元格

swift - 有什么方法可以让我在 Swift 中看到 PhotoScroller?

ios - 在 swift 3 中使用 parse API,只保存一些查询结果?

ios - nodeBlockForRowAtIndexPath 中的异步调用