ios - How to add label or text in to CAShapeLayer -
here class , it'll draw circle, looks this:
class ovallayer: cashapelayer { let animationduration: cftimeinterval = 0.3 override init() { super.init() fillcolor = colors.green.cgcolor path = ovalpathsmall.cgpath } required init?(coder adecoder: nscoder) { fatalerror("init(coder:) has not been implemented") } var ovalpathstart: uibezierpath { let path = uibezierpath(ovalinrect: cgrect(x: 0.0, y: 0.0, width: 100.0, height: 100.0)) return path } }
now need add text middle of circle, tried find on google nothing works fine. not sure if it's possible or not, can me if it's possible?
i guess should add catextlayer
sublayer calayer
... works fine way: try adding cashapelayer
first, , catextlayer
(to same calayer
parent layer), example in following order...
// assume self - uiview instance self.layer.addsublayer(shapedlayer) // shapedlayer - cashapelayer instance self.layer.addsublayer(textlayer) // textlayer - catextlayer instance
Comments
Post a Comment