美文网首页
用 UIBezierPath 画指定UIRectCornerTo

用 UIBezierPath 画指定UIRectCornerTo

作者: 天空中的球 | 来源:发表于2020-05-09 00:46 被阅读0次

用UIBezierPath 画指定圆角不生效, 明明设置了 左上角和右上角,结果只有左上角才变圆了。

    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor orangeColor];
    view.frame = CGRectMake(100, 100, 100, 100);
    [self.view addSubview:view];
        
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = view.bounds;
    maskLayer.path = maskPath.CGPath;
    view.layer.mask = maskLayer;
正常的

经过测试,我同时设置 UIRectCornerTopLeft|UIRectCornerBottomLeft 生效了, 但 设置 UIRectCornerTopRight|UIRectCornerBottomRight 不生效, 那是否可以判断此处设置右边圆角就有问题的呢

实际的

后来重新设置下 View 的 Frame 就好了

相关文章

网友评论

      本文标题:用 UIBezierPath 画指定UIRectCornerTo

      本文链接:https://www.haomeiwen.com/subject/ksjoghtx.html