【发布时间】:2019-08-26 16:09:17
【问题描述】:
我正在尝试设置一个图像和标题垂直对齐的按钮,以便标题位于图像下方。谷歌搜索说按钮不显示标题的原因是图像边缘将标题推开。但是当我设置边缘时,我仍然看不到标题。
我的按钮以编程方式设置如下:
private let dislikeButton = UIButton()
dislikeButton.contentMode = .scaleAspectFit
dislikeButton.setTitle(String.Localized.Button.dislike, for: .normal)
dislikeButton.setTitleColor(.white, for: .normal)
dislikeButton.setImage(UIImage.leftPaw, for: .normal)
dislikeButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 150)
dislikeButton.titleEdgeInsets = UIEdgeInsets(top: 50, left: 150, bottom: 0, right: 0)
按钮高度设置为 100,宽度设置为屏幕宽度的一半。
谁能看到我错过了什么?
【问题讨论】: