【问题标题】:How to change the background color of an UIButton?如何更改 UIButton 的背景颜色?
【发布时间】:2021-11-04 08:35:57
【问题描述】:

我正在尝试做一些非常简单的事情,为了美观而更改 UIButton 的背景...但我找不到背景属性,因为其他所有按钮似乎都很清晰(没有明确的背景颜色)

func updateNewButton() {
    if newButton == true {
        let buttonFont = self.ButtonFont

        self.subscribeButton.SetAttributedTitle(title: StoreKit.sharedInstance.ButtonStateText, withFont: buttonFont, textColor: storeBackground, for: .normal)
    }

【问题讨论】:

标签: swift uibutton


【解决方案1】:

更改UIButton的背景颜色:

self.subscribeButton.backgroundColor = .yourDesiredColor

要更改UIButtontitleLabel 的背景颜色:

self.subscribeButton.titleLabel?.backgroundColor = .yourDesiredColor

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-22
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    • 1970-01-01
    • 1970-01-01
    • 2013-01-09
    相关资源
    最近更新 更多