ios - UIBezierPath for Rounding Corner of Button not work properly -
i made class uibutton , override awakefromnib. next (green button) use class.
i have space in right of next button (green one). space more in ipad:
override func awakefromnib() { super.awakefromnib() let path = uibezierpath(roundedrect: self.bounds, byroundingcorners: [.topleft, .bottomleft], cornerradii: cgsizemake(5, 5)) let masklayer = cashapelayer() masklayer.path = path.cgpath self.layer.mask = masklayer self.layer.bordercolor = mycolor.nextbuttonborder.cgcolor }
you should put code in
layoutsubviews()
method. don't forget delete previous added masklayer.
full example:
override func layoutsubviews() { super.layoutsubviews() self.layer.mask = nil let path = uibezierpath(roundedrect: self.bounds, byroundingcorners: [.topleft, .bottomleft], cornerradii: cgsizemake(5, 5)) let masklayer = cashapelayer() masklayer.path = path.cgpath self.layer.mask = masklayer self.layer.bordercolor = mycolor.nextbuttonborder.cgcolor }
Comments
Post a Comment