ios - 在 UIFont 上设置行高
问题描述
我了解您可以在 UI 标签和 UItextview 上设置行高。但是,我的问题是如何设置 UIfont 的行高?这可能吗?
做这样的事情是行不通的,因为 line-height 是一个 get only 属性,它似乎不是UIFont的一个minimum line Height
或属性maximum line Height
let font = UIFont.systemFont(ofSize: 12, weight: .bold)
font.lineHeight = 12
解决方案
You can see the value of lineheight of your font via this extension :
CGFloat GetLineHeightForFont(CTFontRef iFont)
{
CGFloat lineHeight = 0.0;
check(iFont != NULL);
// Get the ascent from the font, already scaled for the font's size
lineHeight += CTFontGetAscent(iFont);
// Get the descent from the font, already scaled for the font's size
lineHeight += CTFontGetDescent(iFont);
// Get the leading from the font, already scaled for the font's size
lineHeight += CTFontGetLeading(iFont);
return lineHeight;
}
推荐阅读
- grpc - GRPC-gateway 默认 healthCheck 支持
- cucumber - 如何在 Jira Xray 的测试执行中发送测试信息?
- smalltalk - Pharo Monticello 中的“消息不被理解”失败
- grpc - 从 Cloud Build 连接到 GKE 集群上的 gRPC 服务
- javascript - 当它没有改变大小时如何停止改变大小
- php - 使用 HTML 表单连接到数据库并获取用于制作表格的数据
- c# - 无法进入异步任务
- mysql - 如何在 linux debian 10 (Google Pixelbook) 上安装 mysql workbench
- react-native - ScrollView react native 不显示具有绝对位置的子项
- i3 - 编辑shell命令的基本rofi用法