Different font size for UILabel using adaptive layout

谁说胖子不能爱 提交于 2019-12-10 02:36:54

问题


In Xcode 6 we have a new feature called adaptive layout. By using that I have created a new project in which it I need to have different font size based on the layout.

In iPhone 3.5 inch screen I must have font size as 17pt, and other screen size in iPhone must be 21pt.

Can anyone tell me how I can achieve this using adaptive layout?


回答1:


Yes, you can do with storyboad. There is a + sign on the left of the font, click it and select the size class and choose the font size needed




回答2:


In viewDidAppear or viewWillAppear, you can detect the size of the layout. You only have to update font size based on the detected size.
You can use [[UIScreen mainScreen] bounds]; or in iOS8 : [[UIScreen mainScreen] nativeBounds];



来源:https://stackoverflow.com/questions/26236145/different-font-size-for-uilabel-using-adaptive-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!