문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top