ios - 是什么干扰了 UIButton 内的自定义插图?
问题描述
当我注意到这种令人惊讶的行为时,我正在使用John Sundell 的Applying rounded corners to a UIKit or SwiftUI view in a Playground 中的代码,零边缘插入设置确实会导致 UIButton 内部有一些 y 轴填充,而添加严格的正 x -axis insets 确实删除了 y 轴填充。知道是什么解释了这种行为吗?
解决方案
来自 Apple 的UIButton .contentEdgeInsets文档:
... 默认值为零。
该按钮使用此属性来确定intrinsicContentSize 和sizeThatFits(_:)。
虽然不清楚,如果.contentEdgeInsets
它们是默认的,UIKit 会添加默认的顶部和底部“填充”。
如果任何值不是默认值零,UIKit 会假定您已完全按照您的需要设置这些值。
推荐阅读
- asp.net - 从 3.5 升级到 4.0,asp 菜单悬停在不工作
- excel - 使用 Openpyxl 将数据框附加到现有 Excel 工作表
- airflow - 创建 dag 运行时将参数传递给 Airflow Experimental REST api
- python - 如何整合所有区间?
- c# - WCF 服务仅返回基类
- amazon-web-services - AWS Route53 按过期搜索/排序域
- javascript - 隐藏/显示按钮在 jquery 中不起作用
- docker - docker pull 中发生错误
- c# - 更改分离子对象的父级 - 实体框架 6
- r - 根据条件创建新的数值变量