Please help to judge whether drawing text on UIView uses CPU more or its the same as we use UILabel and update the text in it at run time(while scrolling). Eg. the way gmail shows profile pic of user by its name's initials.

- 689
- 8
- 19
-
check this url : https://stackoverflow.com/questions/510382/how-do-i-create-a-round-cornered-uilabel-on-the-iphone – Bhadresh Sonani Aug 24 '17 at 08:31
-
Drawing a text on UIView Better – Saurabh Jain Aug 24 '17 at 08:32
-
1label is better as it is easier to manage an edit where UIView add a layer of complexity to it. In terms of performance it may not make much difference. But in terms of coding and managing it makes difference – cole Aug 24 '17 at 08:33
-
@bhadresh Sonani: I do know how to create circular label. Just wanted to know which approach is better. Thanks for replying. – Apogee Aug 24 '17 at 08:36
-
@cole: That makes sense. Thanks. – Apogee Aug 24 '17 at 08:40
-
@Saurabh Jain: Could you please explain a little more your point of view. As cole has suggested and explained something totally opposite to your point. Thanks – Apogee Aug 24 '17 at 08:40
-
Glad could help you. I posted my reply as answer and if you are happy, please accept my answer. – cole Aug 24 '17 at 08:43
-
Accepted!!!! :D – Apogee Aug 24 '17 at 09:02
3 Answers
Most programs do some amount of drawing. If your program uses only standard windows and controls, then you probably do not need to worry too much about drawing performance. However, if you do any custom drawing, you need to monitor your drawing code and make sure it is performing at acceptable levels. In particular, if you support any of the following, you should investigate ways to optimize your drawing code.
- Live resizing
- Custom view drawing code, especially if portions of the view can be updated without updating the whole view
- Textured graphics
- Entirely opaque views
The way gmail shows profile pic of user by its name's initials can be easily achieve easily using this library.

- 4,737
- 1
- 32
- 47
-
Got it. Thanks for sharing the link for performance guidelines. I sometimes get lost in getting the helpful guidelines provided by apple. :} – Apogee Aug 24 '17 at 08:48
-
1
label is better as it is easier to manage an edit where UIView add a layer of complexity to it. In terms of performance it may not make much difference. But in terms of coding and managing it makes difference.
In end, it depend on your app requirement.

- 3,147
- 3
- 15
- 28
What I suggest is using a UILabel instead of UIView, for it to be both your view and your label.
let yourLabel = UILabel(x0:, y:0, width:100, height:100)
yourLabel.backgroundColor = UIColor.red
yourLabel.textAligment = NSTextAligment.center
yourLabel.layer.cornerRadius = yourLabel.frame.size.widht/2
yourLabel.textColor = UIColor.white
yourLabel.text = "M"
self.view.addSubview(yourLabel)

- 2,077
- 1
- 11
- 17