我正在通过UIBezierPath在uiview上制作弧线。它正在制作精细的弧形但是当我拍摄这个UIView的快照以进行共享时,弧线不会显示在快照中。 uiview显示为默认值,并且弧形和圆形rectcorners未显示。这是快照的代码 CGSize sz = CGSizeMake(bottomview.frame.size.width,bottomview.frame.size.height);
UIGraphicsBeginImageContext(sz);
[bottomview.layer renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
resultImageView.image=image;
这里是制作弧的代码 UIBezierPath * aPathbottom = [UIBezierPath bezierPath];
[aPathbottom moveToPoint:CGPointMake(0, 262)];
[aPathbottom addLineToPoint:CGPointMake(0, 15)];
[aPathbottom addLineToPoint:CGPointMake(10, 10)];
[aPathbottom addLineToPoint:CGPointMake(20, 6)];
[aPathbottom addLineToPoint:CGPointMake(40, 3.5)];
[aPathbottom addLineToPoint:CGPointMake(60, 6)];
[aPathbottom addLineToPoint:CGPointMake(70, 10)];
[aPathbottom addLineToPoint:CGPointMake(80,15)];
[aPathbottom addLineToPoint:CGPointMake(80, 250)];
[aPathbottom addLineToPoint:CGPointMake(70, 256)];
[aPathbottom addLineToPoint:CGPointMake(60, 260.5)];
[aPathbottom addLineToPoint:CGPointMake(50, 264)];
[aPathbottom addLineToPoint:CGPointMake(55, 264.5)];
[aPathbottom addLineToPoint:CGPointMake(40, 265)];
[aPathbottom addLineToPoint:CGPointMake(45, 264.5)];
[aPathbottom addLineToPoint:CGPointMake(40, 264)];
[aPathbottom addLineToPoint:CGPointMake(20, 260.5)];
[aPathbottom addLineToPoint:CGPointMake(10, 256)];
[aPathbottom addLineToPoint:CGPointMake(0, 250)];
[aPathbottom closePath];
CAShapeLayer *maskLayerbottom = [CAShapeLayer layer];
maskLayerbottom.frame = bottomview.bounds;
maskLayerbottom.path = aPathbottom.CGPath;
bottomview.layer.mask = maskLayerbottom;
我不知道为什么会这样。可以帮助我。
问候 chakshu arora
答案 0 :(得分:2)
我得到了我试过的答案
[bottomview.layer addSublayer:maskLayerbottom];
位于bottomview.layer.mask = maskLayerbottom;
,UIView
的快照显示弧线。
答案 1 :(得分:1)
您是否尝试过添加此内容?
[bottomview.layer setMasksToBounds:YES];