【问题标题】:What is interferring with this custom insets inside a UIButton?什么会干扰 UIButton 内的自定义插入?
【发布时间】:2021-04-29 04:20:33
【问题描述】:

当我注意到这种令人惊讶的行为时,我正在 Playground 中使用 John Sundell's Applying rounded corners to a UIKit or SwiftUI view 的代码,零边缘插入设置确实会导致 UIButton 内部出现一些 y 轴填充,而添加严格的正 x 轴插入确实会删除y 轴填充。知道是什么解释了这种行为吗?

【问题讨论】:

    标签: ios xcode uibutton uikit


    【解决方案1】:

    来自 Apple 的 UIButton .contentEdgeInsets 文档:

    ...默认值为零。

    按钮使用此属性来确定intrinsicContentSize 和sizeThatFits(_:)。

    虽然不清楚,但如果 .contentEdgeInsets 是默认值,UIKit 会添加默认的顶部和底部“填充”。

    如果任何值在默认为零时不是,UIKit 会假定您已完全按照您的需要设置这些值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-06
      • 1970-01-01
      • 1970-01-01
      • 2018-12-26
      相关资源
      最近更新 更多