关于label等uiview的圆角问题

来源:互联网 发布:mysql数据库篡改 黑客 编辑:程序博客网 时间:2024/06/05 19:13

其实写过很多uiview的圆角的,总是拿到layer来设置圆角,运用在cell的重用中也基本没有发现卡顿现象,应该是因为在cell中对uiview的数量是比较少的,因此会很少出现卡顿的效果,参考cocoachina中的一篇文章:http://www.cocoachina.com/ios/20150803/12873.html,因此会有这个卡顿出现,但是在数量少的情况下基本没有影响,如果想要避免这个情况,做法有很多。诸如ui你直接切那么一张图片肿么样,或者赋一层uiview,在或者重绘,如下:
文/孤独的前进着(简书作者)
原文链接:http://www.jianshu.com/p/5d83c6ec1dfe
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

  • (void)drawRect:(CGRect)rect
    {
    CGContextRefcontext=UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor(context,0,0,1,1);
    CGContextAddArc(context,headerCenterWidth,headerCenterHeight,headerRadius,radians((180-headerClipHalfAngle)),radians(-180+headerClipHalfAngle),1);
    CGContextAddArcToPoint(context,
    headerCenterWidth- (headerRadius*sin(radians(90-headerClipHalfAngle)) -headerRadius*sin(radians(headerClipHalfAngle)) *tan(radians(headerClipHalfAngle))),
    headerCenterHeight,
    headerCenterWidth-headerRadius*sin(radians(90-headerClipHalfAngle)),
    headerCenterHeight+headerRadius*sin(radians(headerClipHalfAngle)),
    headerRadius);
    CGContextClosePath(context);
    CGContextClip(context);
    UIImage*image2=[UIImageimageNamed:@”1”];
    [image2drawAtPoint:CGPointMake(0,0)];
    }
    如此,在试试效果如何,其实笨方法真的我没感觉到卡顿。。
0 0
原创粉丝点击