Domanda

I'm finishing up a custom UIControl. I need to show some text on the control, but I am not sure what is better praxis: add a label as a subview or draw the text inside the drawRect method. I've seen both methods, but I'm unsure what is better implementation praxis. The text doesn't need to be formated, just plain text would do fine.

È stato utile?

Soluzione

Both methods are just fine. However you have better maintenance/control over a UILabel then your drawRect: method. You can access the label from outside sources and update it whenever you want without the need to call a updateLayout function (a trigger to call the drawRect).

So I advice you to use a label.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top