How to set cornerRadius for only top-left and top-right corner of a UIView?

后端 未结 26 2953
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 06:14

Is there a way to set cornerRadius for only top-left and top-right corner of a UIView?

I tried the following, but it end up not seeing the

26条回答
  •  清酒与你
    2020-11-22 07:09

    This would be the simplest answer:

    yourView.layer.cornerRadius = 8
    yourView.layer.masksToBounds = true
    yourView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
    

提交回复
热议问题