Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我创建了一个 UIView 并将它放在一个 imageView 的顶部,并将 uiview 的背景颜色设置为 clearcolor,所有的绘图都发生在那个 UIView 上,如何才能擦除我在那个 uiview 上画的线?谢谢。
您是否尝试CGContextSetBlendMode(context, kCGBlendModeClear)过然后绘制要擦除的区域。CGContextClearRect如果要清除整个屏幕(或其矩形部分),也可以使用清除上下文。
CGContextSetBlendMode(context, kCGBlendModeClear)
CGContextClearRect
在您的视图上调用 setNeedsDisplay ,下次 drawRect 不画线,而是用 clearColor 填充整个边界