UITextView font to always be fixed size

一曲冷凌霜 提交于 2019-11-29 17:32:16

Coding

var fontSize : CGFloat = 12.0 // DEFAULT SIZE

In your ViewDidLoad

if UIDevice().userInterfaceIdiom == .phone {
    switch self.view.frame.size.height {
    case 480:
        fontSize = 12.0
    case 568:
        fontSize = 14.0
    case 667:
        fontSize = 16.0
    case 736:
        fontSize = 17.0
    case 812:
        fontSize = 18.0
    default:
        print("unknown")
    }
}
else if UIDevice().userInterfaceIdiom == .pad {

    fontSize = 20.0

}

Then apply this fontSize, wherever u need.

Storyboard

Select UITextView, in Attributes Inspector area, + (plus) symbol is near to Font. By default it will work for iPhone devices. For iPad, Change change size classes to Regular width and Regular Height wR hR . For, that U can increase font size.

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