来自UIview的快照不显示圆弧和圆角

问题描述:

我正在通过UIBezierPath制作uiview上的圆弧。它正在做精细的圆弧,但是当我将此UIView的快照用于共享圆弧时,不会显示在快照中。 uiview显示为默认值,弧形和圆形rectcorner不显示。这里是快照代码 CGSize sz = CGSizeMake(bottomview.frame.size.width,bottomview.frame.size.height);来自UIview的快照不显示圆弧和圆角

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阿罗拉

我有我的地方bottomview.layer.mask = maskLayerbottom;试图
[bottomview.layer addSublayer:maskLayerbottom];的答案,从UIView正在显示弧快照。

您是否尝试过加入这个?

[bottomview.layer setMasksToBounds:YES]; 
+0

不是它不工作..... – chakshu 2013-04-12 04:07:03