滚动圆角卡顿--有效(不是唯一)

来源:互联网 发布:上海女人护肤品 知乎 编辑:程序博客网 时间:2024/06/03 16:24
-(void)kt_addCorner:(CGFloat)radius{    if (self.image) {        self.image = [self.image imageAddCornerWithRadius:radius andSize:self.bounds.size];    }    return;}- (UIImage*)imageAddCornerWithRadius:(CGFloat)radius andSize:(CGSize)size{    CGRect rect = CGRectMake(0, 0, size.width, size.height);    UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);    CGContextRef ctx = UIGraphicsGetCurrentContext();    UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(radius, radius)];    CGContextAddPath(ctx,path.CGPath);    CGContextClip(ctx);    [self drawInRect:rect];    CGContextDrawPath(ctx, kCGPathFillStroke);    UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();    return newImage;}

这里写链接内容

0 0