目标是这样的:
所以我用框架绘制视图:
CGfloat round = 80;UIVIEw *myVIEw = [[UIVIEw alloc] initWithFrame:CGRectMake(self.frame.size.wIDth/2-105,210,60+round)];myVIEw.backgroundcolor = [UIcolor redcolor];
然后尝试添加BezIErMask:
UIBezIErPath *aPath = [UIBezIErPath bezIErPath];CGSize vIEwSize = CGSizeMake(myVIEw.frame.size.wIDth,myVIEw.frame.size.height); //(210,80)CGPoint startPoint = CGPointMake(myVIEw.frame.origin.x,myVIEw.frame.origin.y); //(279,0)[aPath movetoPoint:startPoint]; //(279,0)[aPath addlinetoPoint:CGPointMake(startPoint.x+vIEwSize.wIDth,startPoint.y)]; //(489,0)[aPath addlinetoPoint:CGPointMake(startPoint.x+vIEwSize.wIDth,startPoint.y+vIEwSize.height-round)]; //(489,60)[aPath addQuadCurvetoPoint:CGPointMake(startPoint.x,startPoint.y+vIEwSize.height-round) controlPoint:CGPointMake(startPoint.x+(vIEwSize.wIDth/2),80)]; //(279,60) : (384,80)[aPath closePath];CAShapeLayer *layer = [CAShapeLayer layer];layer.frame = myVIEw.bounds;layer.path = aPath.CGPath;myVIEw.layer.mask = layer;[self addSubvIEw:myVIEw];
但在那之后我的观点正在逐渐消失.为什么?
解决方法 我猜你正在使用不正确的掩码层协调.您的遮罩层必须位于遮罩的视图内,而不是在视图的超级视图中.尝试以下更改:
CGSize vIEwSize = myVIEw.bounds.size;CGPoint startPoint = CGPointZero;
使用这些小修改的代码对我来说很合适.
总结以上是内存溢出为你收集整理的ios – BezierPath和掩蔽全部内容,希望文章能够帮你解决ios – BezierPath和掩蔽所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)