// Make text white... and background blue
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor blueColor]];
是否应该制作一个带有白色文本……和蓝色背景的按钮? 它没有。
最佳答案
听起来您的按钮属于 UIButtonTypeRoundedRect
类型。下面的链接应该可以回答您的问题。
Is it even possible to change a UIButtons background color?
然而,我所做的只是不给它一个类型。
UIButton *myButton = [[UIButton alloc] init];
[myButton setBackgroundColor:[UIColor blueColor]];
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
虽然看起来不像那样花哨。
关于objective-c - 如何制作带有白色文字的蓝色按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2503650/