我试图只围绕我的桌面视图的右上角和左上角。我正在使用下面的代码,它似乎只是绕过左上角...
CAShapeLayer *topLayer = [CAShapeLayer layer];
UIBezierPath *roundedPath =
[UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(9.f, 9.0f)];
topLayer.path = [roundedPath CGPath];
答案 0 :(得分:2)
希望这会奏效。 找到创建遮罩层的顶角路径
UIBezierPath *PathToMask;
PathToMask = [UIBezierPath bezierPathWithRoundedRect:self.testView.bounds
byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
cornerRadii:CGSizeMake(8.0, 8.0)];
使用UIBezierPath maskPath
创建形状图层蒙版CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame =self.testView.bounds;
maskLayer.path = PathToMask.CGPath;
设置遮罩层maskLayer
self.testView.layer.mask = maskLayer;