美文网首页
使用贝塞尔曲线裁圆优化tableView

使用贝塞尔曲线裁圆优化tableView

作者: NateLam | 来源:发表于2016-09-07 11:19 被阅读29次
  1. 最简单还是还设计师要个图, 四周与背景色一直, 中间透明, 直接覆盖上去即可
  1. 建一个UIView的category

添加以下方法并声明出去

- (void)setAllCornerWithRoundedCornersSize:(CGFloat)cornersSize {
    UIBezierPath *maskPath;
maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:cornersSize];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.bounds;
    maskLayer.path = maskPath.CGPath;
    self.layer.mask = maskLayer;
}

在cell类中引入刚才这个类, 然后在- (void)layoutSubviews{}方法中用需要裁圆的imageView, 调用这个方法即可, conerSize就是边长的一半

顺便贴个原始方法

_imageViewOfPic.layer.cornerRadius = 40;     
_imageViewOfPic.layer.masksToBounds = YES;

调用还是和第二个方法一样

相关文章

网友评论

      本文标题:使用贝塞尔曲线裁圆优化tableView

      本文链接:https://www.haomeiwen.com/subject/pgsjettx.html