美文网首页
一个使用UIBezierPath搭配UIImage做的简易画板

一个使用UIBezierPath搭配UIImage做的简易画板

作者: 狂暴的土豆泥 | 来源:发表于2021-07-13 14:34 被阅读0次
效果图

拥有的功能:
1、每条线段不同颜色
2、橡皮擦
3、撤回/清屏/重绘
4、外部传入参数绘制(场景:使用即时通信同步画画界面)

核心代码:

- (void)drawRect:(CGRect)rect {
    
    if (self.drawResult) {
        [self.drawResult drawInRect:self.bounds];
    }
    
    if (self.currentPath) {
        if (self.isEraser) {
            [self.currentPath strokeWithBlendMode:kCGBlendModeClear alpha:1.0];
            [UIColor.clearColor setStroke];
        } else {
            [self.currentPath strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
            [self.lineColor setStroke];
        }
        [self.currentPath stroke];
    }
    
}

码云

有问题和想法的可以评论我。

相关文章

网友评论

      本文标题:一个使用UIBezierPath搭配UIImage做的简易画板

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