【问题标题】:How to crop the UIImage to have rounded corener [duplicate]如何裁剪 UIImage 以使其具有圆形核芯 [重复]
【发布时间】:2014-09-17 06:29:01
【问题描述】:

我有一个要求,我需要用指定的半径裁剪 UIImage 的右上角和右下角。最终输出应如下图所示

有谁能帮帮我吗?

【问题讨论】:

    标签: ios objective-c uiimageview uiimage


    【解决方案1】:
    UIBezierPath *maskPath;
    maskPath = [UIBezierPath bezierPathWithRoundedRect:_backgroundImageView.bounds byRoundingCorners:(UIRectCornerTopRight | UIRectCornerBottomRight)cornerRadii:CGSizeMake(5.0, 5.0)];
    
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.bounds;
    maskLayer.path = maskPath.CGPath;
    _backgroundImageView.layer.mask = maskLayer;
    

    self 是我的自定义表格视图单元格。

    【讨论】:

    【解决方案2】:

    简单的方法

     ImageView.layer.cornerRadius  = 10.0f;
        ImageView.layer.borderWidth = 1.0f;
        ImageView.layer.borderColor = [[UIColor  whiteColor] CGColor];
    

    并用相同的背景颜色覆盖左侧。然后会出现右上角和右下角的样子

    【讨论】:

    • 它适用于图像的所有角落。
    • 检查我的更新答案
    猜你喜欢
    • 2011-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-19
    • 1970-01-01
    • 2019-08-08
    • 2018-12-31
    • 2019-02-07
    相关资源
    最近更新 更多