ios - How to add label or text in to CAShapeLayer -


here class , it'll draw circle, looks this:

enter image description here

    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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -