swift - how to set cornerRadius for only bottom-left,bottom-right and top-left corner textview? -
how set corner radius only bottom-left,bottom-right , top-left corner textview?
let rectshape = cashapelayer() rectshape.backgroundcolor = uicolor.redcolor().cgcolor rectshape.bounds = messages.frame rectshape.position = messages.center rectshape.path = uibezierpath(roundedrect: messages.bounds, byroundingcorners: .bottomleft | .topright, cornerradii: cgsize(width: 20, height: 20)).cgpath messages.layer.addsublayer(rectshape)
this code create 2 rect. dont know why.
you need mask layer shown below:
for swift 3:
let rectshape = cashapelayer() rectshape.bounds = self.myview.frame rectshape.position = self.myview.center rectshape.path = uibezierpath(roundedrect: self.myview.bounds, byroundingcorners: [.bottomleft , .bottomright , .topleft], cornerradii: cgsize(width: 20, height: 20)).cgpath self.myview.layer.backgroundcolor = uicolor.green.cgcolor //here i'm masking textview's layer rectshape layer self.myview.layer.mask = rectshape
lower version:
let rectshape = cashapelayer() rectshape.bounds = self.myview.frame rectshape.position = self.myview.center rectshape.path = uibezierpath(roundedrect: self.myview.bounds, byroundingcorners: .bottomleft | .bottomright | .topleft, cornerradii: cgsize(width: 20, height: 20)).cgpath self.myview.layer.backgroundcolor = uicolor.greencolor().cgcolor //here i'm masking textview's layer rectshape layer self.myview.layer.mask = rectshape
Comments
Post a Comment