Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何使用UIBezierPath在一个遮罩顶部绘制多个矩形剪切_Ios_Objective C_Uibezierpath - Fatal编程技术网

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()