0

I can set the title for the normal state with this:

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

However this doesn't set the title for the button's disabled state. To accomplish this, I tried adding the following:

buttonNode.setAttributedTitle(buttonTitle, for: .disabled)

However this then removes the tile for the normal state. There is no ASControlState.normal.

How can I set the button's title to be the same in all states?

Justin Vallely
  • 5,932
  • 3
  • 30
  • 44

2 Answers2

0

The button title can be set for all states by setting an empty array for the ASControlState:

let buttonTitle = NSAttributedString(string: "Book", attributes: attributes)
buttonNode.setAttributedTitle(buttonTitle, for: [])
Justin Vallely
  • 5,932
  • 3
  • 30
  • 44
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())
swetansh kumar
  • 475
  • 7
  • 17