我可以在 Storyboard 上像下面这样写代码吗?
let button = UIButton()
button.titleLabel.center = CGPoint(x:button.titleLabel.center.x, y:button.titleLabel.center.y + 30)
最佳答案
查看 UIEdgeInsets
和 UIButton 属性 titleEdgeInsets
。
button.titleLabelInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 30)
根据您的确切需求和代码,这应该可以满足您的需要。 (仅供引用 - 还有一个 imageEdgeInsets
。)
关于swift - 我可以在 Storyboard 上设置偏移位置吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43131684/