简体   繁体   English

如何在iPhone的分组样式UITableView中使用的图像的一个角

[英]How to round a single corner of an image used in a Grouped-style UITableView on iPhone

I have a custom UITableViewCell with a UIImageView that is overlapping the round corners on the first and last cell. 我有一个带有UIImageView的自定义UITableViewCell,它与第一个和最后一个单元的圆角重叠。 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? 鉴于我能够确定哪个单元格是第一个/最后一个,是否有一种简单的方法可以使UIImage的单个角(左上角或左下角)变圆,使其看起来不错?

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 祝你好运

可以使用蒙版或圆角UIImage和正确的混合模式完成圆角的圆角处理。

Ok, using the original addRoundedRectToPath, I was able to accomplish rounding only one corner by adding the follow: 好的,使用原始的addRoundedRectToPath,通过添加以下内容,我只能完成一个角的取整:

commented //CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); 评论了// CGContextAddArcToPoint(context,fw,0,fw,fh / 2,1); // square bottom right and top right edges CGContextAddLineToPoint(context, fw, 0); //右下角和右上角正方形CGContextAddLineToPoint(context,fw,0); CGContextAddLineToPoint(context, fw, fh); CGContextAddLineToPoint(context,fw,fh); CGContextAddLineToPoint(context, fw/2, 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. 我知道有一种更简单的方法可以执行此操作,但是目前可以使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM