I know how to change the background color but what about the actual text? There doesn't seem to be a member on a UIButton called "color" or anything like that. My code:
@IBAction func yellowBtnClicked(sender: UIButton) {
gameboard.image = UIImage(named: "Yellow_gb")
resultsView.image = UIImage(named: "Yellow_results")
colorsView.image = UIImage(named: "Yellow_colors")
colorsBtn.color = UIColor.brownColor() //This line has the issue
}
Use a semi-colon to separate the different style elements in the HTML button tag. Type color: in the quotation marks after "style=". This element is used to change the text color in the button. You can place style elements in any order in the quotation markers after "style=".
</head> <body> <input type="button" onmouseover="ChangeColor()" value="Button" id="btn1" />
There is no property setter color
in UIButton
. use instead setTitleColor
.Write this in viewWillAppear
colorsBtn.setTitleColor(UIColor.brownColor(), forState: UIControlState.Normal)
This will change title color to brown for UIControlState.Normal
To set the color of title
when button is in Highlighted
state use
colorsBtn.setTitleColor(UIColor.brownColor(), forState: UIControlState.Highlighted)
Swift 3.0 example:
colorsBtn.setTitleColor(UIColor .white, for: UIControlState.normal)
colorsBtn.setTitleColor(UIColor .black, for: UIControlState.highlighted)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With