美文网首页
IOS 绘制imageView控件,以满足不规则imageVie

IOS 绘制imageView控件,以满足不规则imageVie

作者: 彼岸花下的暗影 | 来源:发表于2019-06-04 10:51 被阅读0次
    
    - (void)drawRect:(CGRect)rect {
        [super drawRect:rect];
    
        [[UIColor whiteColor] set];
        
        CGFloat radius = rect.size.width / 2;
        
        // 绘制路径
        //---------------------------------------------------------------------------------------------------------------------
        
        UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(radius, radius) radius:radius startAngle:M_PI endAngle:0 clockwise:YES];
        
        [path moveToPoint:CGPointMake(0, radius)];
        
        [path addQuadCurveToPoint:CGPointMake(radius, rect.size.height) controlPoint:CGPointMake(0, radius * 1.5)];
        
        [path addQuadCurveToPoint:CGPointMake(2 * radius, radius) controlPoint:CGPointMake(2 * radius, radius * 1.5)];
        
        // --------------------------------------------------------------------------------------------------------------------
        
        [path fill];
        
        [self.image drawAsPatternInRect:rect];
        
        CAShapeLayer *shapLayer = [CAShapeLayer layer];
        shapLayer.path = path.CGPath;
        self.layer.mask = shapLayer;
        
    }
    
    
    

    相关文章

      网友评论

          本文标题:IOS 绘制imageView控件,以满足不规则imageVie

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