如何将UIButton titleLabel文本显示在其框架的底部。目前,我正在使用UIEdge的上边距,并设置负的UIButton图像宽度,结果不符合预期。我也想将图像中心放置在其框架上。
`

let leftButton: UIButton = {
            let button = UIButton()
            button.layer.borderWidth = 2
            button.layer.borderColor = UIColor.ublGray1().cgColor
            button.setImage(UIImage.init(named: leftButtonImage)?.withRenderingMode(.alwaysTemplate), for: .normal)
            button.tintColor = UIColor.cerulean()
            button.layer.masksToBounds = false
            button.layer.cornerRadius = 37
            button.translatesAutoresizingMaskIntoConstraints = false
            button.setTitle(leftButtonTitle, for: .normal)
            button.titleEdgeInsets = UIEdgeInsets(top: 110, left: -26, bottom: 0, right: 0)[![enter image description here][1]][1]
            button.imageEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)
            button.setTitleColor(UIColor.charcoalGrey(), for: .normal)
            button.titleLabel?.font = UIFont.aspiraMedium(size: 16)
            return button
        }()


`
ios - UIButton titleLabel文本底部到其框架-LMLPHP

最佳答案

您可以尝试这样的事情。

ios - UIButton titleLabel文本底部到其框架-LMLPHP

ios - UIButton titleLabel文本底部到其框架-LMLPHP

10-04 15:13