even-odd(奇偶原则)Apple文档
2020-05-08 本文已影响0人
pluskok
奇偶规则
- (void)drawRect:(CGRect)rect{
CGContextRef ref = UIGraphicsGetCurrentContext();
CGContextAddRect(ref, CGRectMake(300, 300, -200, -200));
CGContextAddRect(ref, CGRectMake(250, 250, -100, -100));
CGContextDrawPath(ref, kCGPathEOFill);
}
Simulator Screen Shot - iPhone SE (2nd generation) - 2020-05-08 at 16.10.06.png
非零环绕规则
- (void)drawRect:(CGRect)rect{
CGContextRef ref = UIGraphicsGetCurrentContext();
CGPoint outter_points[4] = {{100,100},{100,300},{300,300},{300,100}};
CGContextAddLines(ref, outter_points, 4);
CGPoint inner_points[4] = {{150,150},{250,150},{250,250},{150,250}};
CGContextAddLines(ref, inner_points, 4);
// CGContextFillPath(ref);
// 裁剪图片
CGContextClip(ref);
UIImage* image = [UIImage imageNamed:@"me"];
[image drawInRect:rect];
}
Simulator Screen Shot - iPhone SE (2nd generation) - 2020-05-08 at 16.15.12.png