I want to add a rounded rectangle shape in iphone interface but the iphone library doesn't have that object. How do i do it?
A:
Create rounded rectangle image of your interest. you can add this image to different UI Controls.
Jim
2009-12-03 10:37:38
+1
A:
You create an UIView subclass, in which you
#import <QuartzCore/QuartzCore.h>
and set its layer's cornerRadius
property in code to a certain amount:
self.layer.cornerRadius = 5;
self.clipsToBounds = YES;
If you like you could create a property of your object, say roundedCornerRadius
, and listen to its changes using KVO, in a code fragment similar to
[self addObserver: self forKeyPath:@"roundedCornerRadius" options:0 context:nil];
//implement in your UIView subclass
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqual: @"roundedCornerRadius"])
self.layer.cornerRadius = roundedCornerRadius;
}
luvieere
2009-12-03 13:08:21
A:
luvieere's answer worked for me.
Created a UIView subclass to hold the subviews i need to round the corners of. (I used IB).
Set that view to be the view of a UIViewController.
Overloaded viewDidLoad in the view controller to call a custom "viewDidLoad" method in the custom view.
That's where I set the corner radius for the subviews that need rounded corners.
Jon
2010-06-07 00:53:13