【问题标题】:How to add rounded corner at sides of UIView swift 3 [duplicate]如何在UIView swift 3的侧面添加圆角[重复]
【发布时间】:2017-11-27 21:59:57
【问题描述】:

我需要在 UIImageView 上方使用 UIView 在左下角和右下角添加圆角。我使用了 CAShapeLayer,但没有按照我的要求进行裁剪。实现这一点的任何解决方案。

【问题讨论】:

    标签: ios swift swift3 uibezierpath rounded-corners


    【解决方案1】:

    以下是向视图底角添加圆角的方法:

    let path = UIBezierPath(roundedRect:customView.bounds, byRoundingCorners:[.bottomLeft, .bottomRight], cornerRadii: CGSize(width: 50, height:  50))
    let maskLayer = CAShapeLayer()
    maskLayer.path = path.cgPath 
    customView.layer.mask = maskLayer
    

    最终结果:

    您当然必须根据自己的尺寸和颜色进行调整。

    【讨论】:

    • 我需要这种用户界面。但是通过使用您的代码,我无法创建它..我需要为 uiview 添加的所有可能测量是什么...您能解释一下吗?
    • 需要等宽高吗?
    • @IdreesAshraf,不,但结果还是一样。
    【解决方案2】:

    你可以使用 UIView 的扩展

    做得很好here

    您只需将其更改为:

    yourView.roundCorners([.bottomRight, .bottomLeft], radius: YOUR_RADIUS)

    【讨论】:

      猜你喜欢
      • 2021-05-04
      • 2016-01-21
      • 1970-01-01
      • 1970-01-01
      • 2018-01-05
      • 2018-02-21
      • 2018-03-24
      • 1970-01-01
      • 2019-08-07
      相关资源
      最近更新 更多