1

In the iPhone, I can use

view.layer.cornerRadius = 10;

to make the corner round, but I don't want the four corner is rounded, I just want to bottom two round. How can I do so? Thanks.

DNB5brims
  • 29,344
  • 50
  • 131
  • 195
  • possible duplicate of [Round two corners in UIView](http://stackoverflow.com/questions/4847163/round-two-corners-in-uiview) – Brad Larson Dec 13 '11 at 18:54

2 Answers2

1

An easy but a bit ugly solution is to use two layers partially on top of each other so that one of them "hide" the top round corners.

Update found this question Round two corners in UIView which has much more proper and better solutions.

Community
  • 1
  • 1
Mattias Wadman
  • 11,172
  • 2
  • 42
  • 57
0

Here's the solution that I used for a custom table view cell:

Assuming a cell is height 44.

Add a subview with height 66, call it roundedCornerContainer

Within the subview, add cell's content.

Add an IBOutlet to the roundedCornerContainer

When you configure the cell:

#import <QuartzCore/QuartzCore.h>

roundedCornerContainer.layer.cornerRadius = 8;
roundedCornerContainer.layer.masksToBounds = YES;

Don't forget that you need to set your cell's prototype to clip subviews to prevent the roundedCornerContainer from sticking out.

The end result is that the top left and top right corner of the grouped UITableView cell get rounded, while the bottom left and right appear as 90 degree (the bottom rounded corners are clipped by the cell.

If you need to repeat this trick with the bottom grouped cell, simply change the origin of the roundedCornerContainer within the cell's prototype, shifting it's origin 22 points up.

Alex Stone
  • 46,408
  • 55
  • 231
  • 407