0

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

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

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

buttonNode.setAttributedTitle(buttonTitle, for: .disabled)

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

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

4

2 回答 2

0

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

let buttonTitle = NSAttributedString(string: "Book", attributes: attributes)
buttonNode.setAttributedTitle(buttonTitle, for: [])
于 2017-01-16T18:00:08.590 回答
0
fileprivate var noteButtonNode : ASButtonNode = ASButtonNode()

let attributedTitle : NSAttributedString = NSAttributedString(
            string: "Book",
            attributes: [
                NSFontAttributeName: UIFont.init(name: Fonts.Your_font, size: 16)!,
                NSForegroundColorAttributeName: Colors.Your_Color
            ])
        noteButtonNode.setAttributedTitle(attributedTitle, for: ASControlState())
于 2017-10-13T08:01:18.020 回答