我正在尝试使用树形矩形切口创建一个蒙版。是否可以使用UIBezierPath
库?
for (NSUInteger i = 0;i<3;i++)
{
NSDictionary *Def = [self.coachMarks objectAtIndex:i];
CGRect Rect = [[markDef objectForKey:@"rect"] CGRectValue];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRect:self.bounds];
UIBezierPath *cutoutPath = [UIBezierPath bezierPathWithRoundedRect:markRect cornerRadius:self.cutoutRadius];
[maskPath appendPath:cutoutPath];
mask.path = maskPath.CGPath;
}
答案 0 :(得分:0)
我重新安排了整个库,这是我必须更改的主要方法,以便能够在屏幕上指定的任何位置在图层蒙版上绘制多个矩形。要初始化坐标,需要创建一个数组并将其命名为coachMarks。这适用于我的例子。
- (void)goToCoachMarkIndexed:(NSUInteger)index {
markIndex = index;
NSMutableArray *aBezierPaths = [[NSMutableArray alloc] init];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRect:self.bounds];
for (NSUInteger i = 0;i<self.coachMarks.count;i++)
{
NSDictionary *markDef = [self.coachMarks objectAtIndex:i];
CGRect markRect = [[markDef objectForKey:@"rect"] CGRectValue];
[aBezierPaths addObject:[UIBezierPath bezierPathWithRoundedRect:markRect cornerRadius:self.cutoutRadius]];
}
for(NSUInteger i = 0;i<self.coachMarks.count;i++)
{
[maskPath appendPath:[aBezierPaths objectAtIndex:i]];
}
mask.path = maskPath.CGPath;
}