我需要在左上角和右上角设置圆角,但只有左下角和左上角有自动布局。
let path = UIBezierPath(roundedRect: viewWithButtons.bounds, byRoundingCorners: UIRectCorner.TopLeft.union(.TopRight), cornerRadii: CGSize(width: 10, height: 10))
let maskLayer = CAShapeLayer()
maskLayer.frame = viewWithButtons.bounds
maskLayer.path = path.CGPath
viewWithButtons.layer.mask = maskLayer
这是结果: