Ios – how to Change a Rounded Rect UIbutton background color

background-coloriosiphoneuibutton

how to Change UIbutton background color??
I try it on IB, but it doesn't work. only changes it for custom button.

I would like to change the white color on the rounded rect button.

Or instead how to make a custom button whit rounded corners

thanks!

Best Answer

Rounded rect button's color can be changed to any color with the background color property in IB as well as through coding, but can not change its color to transparent color easily. For that, you better use a custom button with either rounded image or set layer as demonstrated in the example and don't forget to add Quartz Core framework in you project as well as to import it in your class.

UIBUtton *myBtn = [UIButton buttonWithType:UIbuttonTypeCustom];
myBtn.frame = frame;    //your desired size
myBtn.clipsToBounds = YES;
myBtn.layer.cornerRadius = 5.0f;
[self.view addSubView:myBtn];