ios - 在 iphone 5 和 iphone 6 中动态设置字体大小

标签 ios fonts iphone-5 iphone-6

在 iOS 8 之后 Apple 引入了对开发者非常有帮助的尺寸等级。但是他们为所有 iPhone(iPhone 4s、iPhone 5、iPhone 5s、iPhone 6)和 iPhone 6 plus 提供了不同的字体大小,那么在 iPhone 5 和 iPhone 6 中是否有任何可能的正确方法来做同样的事情......

我不要支票,请像这样 Set different font size for iPhone 5 and 6

非常感谢您提供合适的最佳答案。

最佳答案

使用下面的宏-

// I assume that iPhone 5 Font size 17.0 and iPhone 6 font size 25.0 and default font size 12.0
#define kFONTSize ([UIScreen mainScreen].bounds.size.height == 568 ? 17.0 :[UIScreen mainScreen].bounds.size.height == 667? 25.0: 12.0)
#define kFONT_DEFINE [UIFont fontWithName:AVENIR_LTPRO size:kFONTSize]

txtView.font = kFONT_DEFINE; 

希望对你有帮助

关于ios - 在 iphone 5 和 iphone 6 中动态设置字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30389345/

相关文章:

ios - UIImagePickerController 每秒显示一次黑屏

ios - 任何人为 iOS 编译模拟

Java (AWT) : fitting text in a box

ios - 加载 iPhone5 图像的 CCZ 压缩文件时出错

ios - 自动调整 iPhone 4S 和 iPhone 5 的 UI 元素

ios - Swift Firebase 删除帖子

android - 如何为事件列表构建 API,以便将来更新

html - 无法将字体加载到 Canvas

css - 在支持 IE 的同时合并字体文件