
例:
- (voID)drawRect:(NSRect)dirtyRect CGContextRef ctx = [[NSGraphicsContext currentContext] graphicsPort]; //Fill the background with gray: CGContextSetRGBFillcolor(ctx,0.5,1); CGContextFillRect(ctx,NSRectTocgRect(self.bounds)); CGContextAddRect(ctx,NSRectTocgRect(self.bounds)); //Add some rectangles: CGContextAddRect(ctx,CGRectMake(10,10,100,100)); CGContextAddRect(ctx,CGRectMake(120,120,50,100)); //Clip: CGContextEOClip(ctx); //Fill the entire bounds with red: CGContextSetRGBFillcolor(ctx,1.0,0.0,1.0); CGContextFillRect(ctx,NSRectTocgRect(self.bounds));}
如果您在最后绘制图像而不是填充红色矩形,则效果会更明显.
总结以上是内存溢出为你收集整理的macos – 使用反向路径的CGContextClip()全部内容,希望文章能够帮你解决macos – 使用反向路径的CGContextClip()所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)