gpt4 book ai didi

ios - 如何设置按钮的背景颜色 - xcode

转载 作者:IT王子 更新时间:2023-10-29 07:56:58 26 4
gpt4 key购买 nike

如何在 Xcode 中设置 UIButton 的背景颜色?

我在布局属性中看到属性 Background 和 Image,但我无法在这两个中设置任何内容。 (我只能设置两种颜色的图像)

最佳答案

只需在 Attribute Inspector 中稍微滚动一下,您就可以在 view 部分找到 Background 属性,它允许您设置 UIButton 的 backgroundColor

enter image description here

如果你想以编程方式设置按钮的backgroundColor

objective-c :

 self.yourButton.backgroundColor = [UIColor redColor];

Swift 3 和 Swift 4

 self.yourButton.backgroundColor = UIColor.red

Swift 2.3 或更低版本

 self.yourButton.backgroundColor = UIColor.redColor()

关于ios - 如何设置按钮的背景颜色 - xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41074243/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com