user2537535
user2537535

Reputation: 43

Changing WKInterfaceLabel Text

I currently have:

@IBOutlet var label: WKInterfaceLabel!

and

 let myString = "Swift Attributed String"
 let myAttribute = [ NSAttributedStringKey.foregroundColor: UIColor.blue ]
 let myAttrString = NSAttributedString(string: myString, attributes: myAttribute)
 label.setAttributedText(myAttrString)

Currently this code does not change the text of the label. Is there something obvious I am missing? Thanks for any help!

Upvotes: 1

Views: 492

Answers (1)

pradip rathod
pradip rathod

Reputation: 368

Your code is working perfectly fine but for only textcolor You do not need to use attributed property you can directly use setTextColor() property.

label.setTextColor(UIColor.blue)
label.setText(myString)

You can refer WKInterfaceLabel and setTextColor

Upvotes: 1

Related Questions