Rounded UIView using CALayers - only some corners - How?

后端 未结 14 2286
南方客
南方客 2020-11-22 13:53

In my application - there are four buttons named as follows:

  • Top - left
  • Bottom - left
  • Top - right
  • Bottom - right

Abov

14条回答
  •  鱼传尺愫
    2020-11-22 14:05

    Thanks for sharing. Here I'd like to share the solution on swift 2.0 for further reference on this issue. (to conform the UIRectCorner's protocol)

    let mp = UIBezierPath(roundedRect: cell.bounds, byRoundingCorners: [.bottomLeft, .TopLeft], cornerRadii: CGSize(width: 10, height: 10))
    let ml = CAShapeLayer()
    ml.frame = self.bounds
    ml.path = mp.CGPath
    self.layer.mask = ml
    

提交回复
热议问题