Stephen
Stephen

Reputation: 4811

iPhone - Buttons background image

I've added some buttons to my app with a background image (RESET button below), but the corners are quite as expected. See below:

alt text

The bottom left and right corners of the RESET button seem to be squared. My original image has rounded corners.

Anyone come across this problem before ?

Upvotes: 9

Views: 2669

Answers (7)

Joseph Tura
Joseph Tura

Reputation: 6360

Check out this blog post: http://www.mlsite.net/blog/?p=232

It has sources for a UIButton+glossy category that allows you to create glossy buttons in apple style. They look pretty much exactly like your buttons. And you wouldn't need to use images at all.

Upvotes: 0

Alex
Alex

Reputation: 919

There's nothing tricky about changing the image for a button(I did it lots of times), as long as you follow a couple of simple steps:

  1. your button image must have a transparent background
  2. your button must be set as Custom (and NOT Round Rect)
  3. your button's background color must have Opacity=0

In order to change the button background color, when you change the color make sure you click on the left side of the color combobox, so that you get presented the color picker. There, you'll have to change the Opacity to 0.

See the image below for a simple demo. alt text

Good luck with your button

Upvotes: 9

Gyani
Gyani

Reputation: 2241

Chek out the the image of the reset button you are using is it in .png format and the image back color is clear color. If the problem persists please again make the image you are using there may be some problem with the image you used.

Upvotes: 0

William Jockusch
William Jockusch

Reputation: 27285

What about not setting the background image for the button, but putting a UIImageView with your desired image directly behind the button?

Upvotes: 0

Steve
Steve

Reputation: 970

What kind of image do you using for that button, is there alpha channel? Also you could try something like this:

yourButton.layer.cornerRadius = 15; // play with this value
yourButton.layer.masksToBounds = YES;

Upvotes: 0

christo16
christo16

Reputation: 4843

An easier solution may be to use something the Three20 framework. It will allow you to create buttons like that (in addition to other styles) without images.

Upvotes: 0

Suresh Varma
Suresh Varma

Reputation: 9740

Chek out the the bottom corners of the reset button are rounded and transparent. also set the backcolor of the button as clearcolor. and make the button custom instead of roundedrect.

I suppose the bottom corners of the buton are not transparent so you are facing the problem.

hAPPY cODING...

Upvotes: 2

Related Questions