Making Rounded UIView’ on iPhone

I have started developing (mainly) iPhone apps late 2009 and I feel like I have some experience on iOS platform that I can share. I won’t be doing tutorial serias but just some tips and tricks.

Let’s start with some ui tips, there are 2 ways to make rounded views in iPhone. One is using layers which is inefficient way, second is using quartz in drawRect.

Using layers is really simple;


YourView *vw = [[YourView alloc] initWithFrame:CGRectMake(20, 20, 80, 80)];
vw.layer.cornerRadius = 16;
vw.layer.masksToBounds = YES;

simple. The right way is to handle in drawRect;

UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(16.0, 16.0)]; //Add a bezier path
[path addClip]; // and clip

Both two will same view.

Related posts:

  1. Java on the iPhone
  2. Featureless iPhone App
  3. Hello World on iPhone
  4. iPhone at Bimeks
  5. iPhone Killer

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>