ios - 如何在layer上实现橡皮擦一样的功能呢
黄舟
黄舟 2017-04-17 16:39:18
0
1
708

比如,我在shapelayer上绘制了一条颜色是红色的UIbezierPath。如何想橡皮擦一样可以擦掉这条线

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
大家讲道理
  1. If you have an image as background, then you can draw the image as a pattern on bezierpath and it will virtually give you an eraser effect. It works :)
    brushPattern=[[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"image.jpg"]];

// Here image.jpg is your background image

  1. The eraser effectively draws a line that is one color, each on top of the background of an already drawn path. What you might want to note is that it is an eraser line so that if the background color changes otherwise you lose the erase you can update the eraser line's stroke color.

  2. Based on your answer to Jeremy, it seems like you are trying to do the dotted line. you setLineDash:number:phase:
    UIBezierPath *path = [UIBezierPath new];

CGFloat dashArray[3];
dashArray[0] = 8;
dashArray[1] = 3;
dashArray[2] = 8;
[path setLineDash:dashArray count:dashCount phase: 0.0];

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!