Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
什么时候对字符串或图像使用drawinrect而不是直接设置值?例如,我可以有一个 uilabel 并将其文本用于字符串,或者我可以使用 [somestring drawInRect:somerect]。同样,我可以在可用的情况下使用 [someimage drawInRect:rect] 或 someview.backgroundImage。
我会说使用 drawInRect 方法是“罕见的”,例如,这种方法用于开发游戏或显示带有大量文本的地图。
问题是,如果您要显示一些简单的东西,例如带有文本字段、uiswitch 等的表单......(如果您不进行复杂的绘图),您应该使用 UILabel。
解释您的项目,我们将能够以比我所说的更好的方式帮助您。
记住:UILabel 是用来显示字符串的;)