I have used story boards to create my view controllers. I have applied auto layouts to all the views and sub views; but the font size is same on all the devices. The only way I know to achieve this is to detect the bounds of the screen and creating the if statement.
if ([[UIScreen mainScreen] bounds].size.height == 568) {
// Assign Font size for iPhone 5
}
else if ([[UIScreen mainScreen] bounds].size.height == 667){
// Assign Font size for iPhone 6
}
else if ([[UIScreen mainScreen] bounds].size.height == 736){
// Assign Font size for iPhone 6+
}
else if ([[UIScreen mainScreen] bounds].size.height == 480){
// Assign Font size for iPhone 4s
}
Question: Is there any other way to implement this ?
Thanks !
如果您使用过UILabel,则可以从情节提要中选择自动收缩选项并设置最小字体比例或最小字体大小。希望这对您有所帮助。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.