PoppinDouble
PoppinDouble

Reputation: 315

Have problems with init(roundedRect:byRoundingCorners:cornerRadii:)

I am using swift 2.0, I am trying to make a view's left top corner and bottom left corner rounded, so I used

init(roundedRect:byRoundingCorners:cornerRadii:)

However, the result is strange, only the left top corner is rounded, the bottom left corner is not working.

here is my code:

let maskPath = UIBezierPath(roundedRect: cell.statusView.bounds, byRoundingCorners: [UIRectCorner.TopLeft , UIRectCorner.BottomLeft], cornerRadii: CGSizeMake(10.0, 10.0)).CGPath
    let maskLayer = CAShapeLayer()
    maskLayer.path = maskPath
    maskLayer.frame = cell.statusView.frame
    cell.statusView.layer.mask = maskLayer

here is the resultenter image description here

Upvotes: 1

Views: 174

Answers (1)

PoppinDouble
PoppinDouble

Reputation: 315

Sorry, I found my own mistake, the problems comes out from the frame and bounds, just change

maskLayer.frame = cell.statusView.frame

into

maskLayer.frame = cell.statusView.bounds

Upvotes: 2

Related Questions