使用NSBezierPath addClip-如何反转剪辑 [英] Using NSBezierPath addClip - How to invert clip
本文介绍了使用NSBezierPath addClip-如何反转剪辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用NSBezierPath addClip仅将绘图限制在用于剪切的路径内.我想做相反的事情-只能在外面画.
Using NSBezierPath addClip only limits drawing to inside the path used for clipping. I'd like to do the opposite - Only draw outside.
- (void)drawRect:(NSRect)dirtyRect {
NSBezierPath *dontDrawInThis = ...;
//We want an opposite mask of [dontDrawInThis setClip];
//Drawing comes here
}
推荐答案
这是我的解决方案:
- (void)drawRect:(NSRect)dirtyRect {
NSBezierPath *dontDrawInThis = ...;
// The mask is the whole bounds rect, subtracted dontDrawInThis
NSBezierPath *clip = [NSBezierPath bezierPathWithRect:self.bounds];
[clip appendBezierPath:dontDrawInThis.bezierPathByReversingPath];
[clip setClip];
//Drawing comes here
}
对于iOS,将NSRect替换为CGRect.
For iOS replace NSRect with CGRect.
这篇关于使用NSBezierPath addClip-如何反转剪辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文