views:

159

answers:

3

I have a custom UITableViewCell with a UIImageView that is overlapping the round corners on the first and last cell. Given that I am able to determine which cell is the first/last, is there an easy method for rounding a single corner (either top-left or bottom-left) of a UIImage so that it will look good?

A: 

Rounding of corners can be done with a mask, or a rounded corner UIImage and the right blend mode.

mahboudz
I've been able to use the very common "addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight)" method, however I was wondering if there was a similar method (that someone else figured out) to round only a single corner to the dimensions of the rounded corner of the first/last UITableViewCell.
Liu Kang
A: 

Ok, using the original addRoundedRectToPath, I was able to accomplish rounding only one corner by adding the follow:

commented //CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); // square bottom right and top right edges CGContextAddLineToPoint(context, fw, 0); CGContextAddLineToPoint(context, fw, fh); CGContextAddLineToPoint(context, fw/2, fh);

  // From here... comment out one of the following...

  // square top left
  CGContextAddLineToPoint(context, 0, fh);
  CGContextAddLineToPoint(context, 0, fh/2);

  // square bottom left
  CGContextAddLineToPoint(context, 0, fh/2);
  CGContextAddLineToPoint(context, 0, 0);
  CGContextAddLineToPoint(context, fw/2, 0);

I know there is an easier way to do this, but that works for now.

Liu Kang
A: 

try this out.

CALayer *l = [img layer];
[l setMasksToBounds:YES];
[l setCornerRadius:5.0];  
[l setBorderWidth:1.0];
[l setBorderColor:[[UIColor blackColor] CGColor]];

best of luck

sugar