Ios 如何使用UIBezierPath在一个遮罩顶部绘制多个矩形剪切
我正在尝试创建一个带有树矩形切口的遮罩。是否可以使用Ios 如何使用UIBezierPath在一个遮罩顶部绘制多个矩形剪切,ios,objective-c,uibezierpath,Ios,Objective C,Uibezierpath,我正在尝试创建一个带有树矩形切口的遮罩。是否可以使用UIBezierPath库执行此操作 for (NSUInteger i = 0;i<3;i++) { NSDictionary *Def = [self.coachMarks objectAtIndex:i]; CGRect Rect = [[markDef objectForKey:@"rect"] CGRectValue]; UIBezierPath *maskPath = [UIBezierPath be
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;
}
for(i=0;i我重新排列了整个库,这是我必须更改的主要方法,以便能够在屏幕上指定的任何位置在层掩码顶部绘制多个矩形。要初始化坐标,需要创建一个数组并将其称为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;
}
-(void)goToCoachMarkIndexed:(nsInteger)索引{
markIndex=index;
NSMutableArray*aBezierPaths=[[NSMutableArray alloc]init];
UIBezierPath*maskPath=[UIBezierPath bezierPathWithRect:self.bounds];
对于(i=0;iyes,这是可能的。我知道,我在下面计算了我所写的内容。请查看我的coachmark库,位于PICoachmarkView.m()