I created a button and when it is clicked, it's background image changes. However the issue is when I click it , it gives a rectangle with a color.
I don't want to see that clicking background.
My codes are below:
let on = UIImage(named: "on") as UIImage
let off = UIImage(named: "off") as UIImage
btn.setBackgroundImage(off, forState: .Normal)
When you use Storyboard buttons which is
IBOutlet UIButton object. By default it is not set as a custom type. So if you set background of this button as an image, It shows border of that button with the image.
For Storyboard variables:
UIButtoncontrol in Storyboard. Go to Attribute Inspector > Change type System to Custom
See the reference images
For programmatically created buttons:
If you create
UIButton object programmatically than set button type as
Objective C Code:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
var button = UIButton.buttonWithType(UIButtonType.Custom) as UIButton