V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
jk234ert
V2EX  ›  iDev

使用 Autolayout 时, UILabel 字体设置为 Hiragino Sans 后,显示英文时部分内容被截断

  •  
  •   jk234ert · 2017-06-06 16:27:35 +08:00 · 3131 次点击
    这是一个创建于 2508 天前的主题,其中的信息可能已经有所发展或是发生改变。

    环境:xCode 8.2 , iOS 10.3.2

    使用 autolayout 的情况下,如下代码:

    open lazy var quizContentLabel: UILabel = {
            let label = UILabel()
            label.numberOfLines = 2
            label.font = TextStyle.QuizContent.font //"Hiragino Sans"
            label.lineBreakMode = .byTruncatingTail
            return label
        }()
    

    label 的 Top, Leading, Trailing 都设了约束,fontSize 为 14

    如果 label 中只设置日文文字,显示出的 label 高度为 28,lineSpacing 为 0,看上去很密集 如果其中有拉丁字母,如 g,y 这种下方超过 baseline 的,就会被截断或者与下一行重叠。

    这里两点很困惑:

    1. Hiragino Sans 字体的 lineSpacing 默认是 0 ?这也太难看了
    2. 拉丁字母系统计算时不处理 descender 吗?

    这种情况是我 autolayout 设置的不够吗?手动 sizeToFit 似乎能解决,但是既然用了 autolayout,还是希望能合理地处理好

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5330 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:50 · PVG 16:50 · LAX 01:50 · JFK 04:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.