I am creating a custom iPhone keyboard, but there is a problem with UIButton
I am using this code to create gradient for my button
let gradient = CAGradientLayer()
gradient.frame = self.bounds
let gradientColors: [AnyObject] = [UIColor(red: 253.0/255, green: 253.0/255, blue: 253.0/255, alpha: 1.0).CGColor, UIColor(red: 253.0/255, green: 153.0/255, blue: 53.0/255, alpha: 1.0).CGColor]
gradient.colors = gradientColors
self.setBackgroundImage(gradient.UIImageFromCALayer(), forState: UIControlState.Normal)
It works great but there is a glitch. it create gradient but add a thin shadow on right and bottom of button.
I also tried not to get gradient, and I added a solid color, but same shadow was there.
Finally I used this code to change background color
self.backgroundColor = UIColor(red: 253.0/255, green: 253.0/255, blue: 253.0/255, alpha: 1.0)
It worked and the shadow wasn't there anymore. but this coused another problem. My button does not change color on Highlighted Stat of UIButton.
Is there any way to get rid of that shadow, or makes UIButton color change on Highlighted state (and also selected state)?
I've tried actually any solution including changing shadow, border and .... but nothing worked. :|
I also tried this :
if (self.state == UIControlState.Normal) {
self.backgroundColor = UIColor(red: 153.0/255, green: 53.0/255, blue: 53.0/255, alpha: 1.0)
}
else if (self.state == UIControlState.Reserved) {
self.backgroundColor = UIColor(red: 253.0/255, green: 253.0/255, blue: 253.0/255, alpha: 1.0)
}
But again did not worked.
Thanks.