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?
views:
159answers:
3
A:
Rounding of corners can be done with a mask, or a rounded corner UIImage and the right blend mode.
mahboudz
2009-09-08 22:29:24
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
2009-09-09 16:44:27
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
2009-09-09 17:04:31
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
2009-09-11 18:24:44