【问题标题】:What are the font attributes of the text in prefersLargeTitles property?prefersLargeTitles 属性中文本的字体属性是什么?
【发布时间】:2021-08-12 23:35:04
【问题描述】:

我正在尝试重新创建 prefersLargeTitles 属性的外观。为此,我想知道是否有人可以告诉我此属性使用的字体和字体大小?

我尝试自己重新创建它的原因是,当我在视图控制器中隐藏导航栏时,prefersLargeTitles 属性会自动禁用和隐藏。因此,我们的目标是将此属性重新创建为自定义 UILabel。

【问题讨论】:

    标签: ios swift user-interface uikit preferslargetitles


    【解决方案1】:

    TL:DR

    Font Color
    SFUI-Bold 34.00pt labelColor

    您可以使用Debug View Hierarchy查看。

    这是所有属性:

    对象

    Class name Address
    UILabel 0x13680d3b0

    标签

    Text Text Lines Behavior
    Title White:0 Alpha:1 (labelColor) 1 Enabled On
    Plain Text .SFUI-Bold 34.00pt Highlighted off
    Aligned Natural
    Baseline Line Break Min Font Scale
    Align Baselines Truncate Tail 0
    Highlighted Shadow Shadow Offset
    nil color nil color w 0 h -1

    查看

    Layer Layer Class Content Mode Tag Interaction
    <_UILabelLayer: 0x600003cae350> _UILabelLayer Left 0 User Interaction Enabled Off, Multiple Touch Off
    Alpha Background Tint
    1 White:0 Alpha:0 (clearColor) R:0 G:0.48 B:1 A:1 (systemBlueColor)
    Drawing
    Opaque On
    Hidden Off
    Clears Graphics Context On
    Clip To Bounds Off
    Autoresize Subviews On

    可访问性(是可访问性元素,不是重点)

    Value Traits Elements Description Hint Identifier Actions
    null Header null Title null null null

    【讨论】:

      【解决方案2】:

      您还可以从Typography section of the Human Interface Guidelines 获取值,因为它们可以在 31pt 到 60pt 之间变化,具体取决于用户选择的动态字体大小。基本尺寸有单独的表格:

      以及可访问性大小:

      如果您出于某种原因想要实现为自定义标签,您可以让动态类型为您执行此操作,而不是指定精确的磅值:

      mylabel.font = UIFont.preferredFont(forTextStyle: .largeTitle)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-17
        • 2015-12-10
        • 2014-02-04
        • 2014-10-23
        • 2019-09-13
        • 2014-09-02
        相关资源
        最近更新 更多