Reputation: 41
i have UIButton with background colour, now i want that Button colour to be set in separate colour filed
i tried by this method :
initialising :
var color1 = UIColor()
color1 = dateBtn1.backgroundColor!
setting :
if color1 == UIColor.lightGrayColor() {
dateBtn1.backgroundColor = UIColor.lightGrayColor()
}else{
dateBtn1.backgroundColor = UIColor(red: 85/255, green: 175/255, blue: 101/255, alpha: 1.0)
}
my crash Report :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -isEqual: not defined for the UIColor <UIPlaceholderColor: 0x7f953241d150>; need to first convert colorspace.'
Upvotes: 3
Views: 2161
Reputation: 1655
It will work. Your issue is with improper Unwrapping and accessing the default button.backgroundColor property.
Upvotes: 3