【问题标题】:snapshot from the UIview is not displaying arcs and roundrect cornerUIview 的快照不显示圆弧和圆角
【发布时间】:2013-04-11 13:38:15
【问题描述】:

我正在通过 UIBezierPath 在 uiview 上制作弧线。弧线做得很好,但是当我拍摄此 UIView 的快照以共享弧线时,快照中没有显示。 uiview 显示为默认值,圆弧和圆角矩形不显示。这是快照的代码 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;

我不知道为什么会这样。谁能帮帮我。

问候 查克苏阿罗拉

【问题讨论】:

    标签: iphone ios uibezierpath quartz-core


    【解决方案1】:

    我得到了我尝试过的答案
    [bottomview.layer addSublayer:maskLayerbottom]; 代替了bottomview.layer.mask = maskLayerbottom; 并且来自UIView 的快照正在显示弧。

    【讨论】:

      【解决方案2】:

      你试过添加这个吗?

      [bottomview.layer setMasksToBounds:YES];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-05-15
        • 2012-07-12
        • 2013-11-23
        • 2018-09-01
        • 2014-09-15
        • 1970-01-01
        • 2010-12-03
        相关资源
        最近更新 更多