PDA

View Full Version : Images for Round Rect




bytezone
May 14, 2009, 12:19 PM
I am trying to put an image dynamicaly to a round rec button. But once I apply the image , the button does not appear as a round rect instead takes the look of square/rectangle.

1. How can I make the round rect btn look like round rect after adding iamge..??

2. Also I would like to display text after adding the image to button..how can I do this....??

3. How to make the button look gradient color....right now I am using a gradient image over btn to make it look like gradient. Any other options..??

Thanks in advance for help....



dejo
May 14, 2009, 12:48 PM
I am trying to put an image dynamicaly to a round rec button. But once I apply the image , the button does not appear as a round rect instead takes the look of square/rectangle.

1. How can I make the round rect btn look like round rect after adding iamge..??

2. Also I would like to display text after adding the image to button..how can I do this....??

3. How to make the button look gradient color....right now I am using a gradient image over btn to make it look like gradient. Any other options..??

Thanks in advance for help....
1. You can't.
2. The UICatalog (http://developer.apple.com/iphone/library/samplecode/UICatalog/index.html) sample app show you how to do this.
3. With a gradient image. See answer for #2.

kainjow
May 14, 2009, 01:16 PM
For #1 you'd have to clip the image to the rounded rect, which is most likely just an image. You could do this by subclassing the button and setting the clip in the drawRect method, or clip the image before setting it as the image. This will be of help. (http://snipplr.com/view/8559/draw-round-rect-with-coregraphics/)