0

I know that I can make UIView with Rounded Corner as

view.layer.cornerRadius = 10;

Now I would like to know how can I make round corner on selected corners? Like making it on top left and top right and not in bottom left and bottom right. How could I do these?

Thanks in advance...

rakeshNS
  • 4,077
  • 4
  • 25
  • 40
  • Even though not exact duplicate, I found answer through those posts. Thank you very much for your findings – rakeshNS Mar 20 '12 at 17:12
  • Dupe close votes / links are dual purpose - they prevent duplication, but they are also to help the questioner (and anyone else who searches using terms you used) find their way to an answer they may not have come across before asking the question. – jrturton Mar 20 '12 at 17:34

2 Answers2

0

two methods:

1. use CALayer mask, mask out the corner you don't want.

or

2. use Core Graphic, create a clip path.
Wubao Li
  • 1,728
  • 10
  • 13
0

Something like this will draw only top corners -

- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];

UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(44.5, 12.5, 69, 46) byRoundingCorners: UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii: CGSizeMake(10, 10)];
[[UIColor whiteColor] setFill];
[roundedRectanglePath fill];

[[UIColor blackColor] setStroke];
roundedRectanglePath.lineWidth = 0.5;
[roundedRectanglePath stroke];

}

Injectios
  • 2,727
  • 1
  • 28
  • 48