// Make text white... and background blue
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor blueColor]];
是否应该制作一个带有白色文本的按钮......和蓝色背景?它没有。
// Make text white... and background blue
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor blueColor]];
是否应该制作一个带有白色文本的按钮......和蓝色背景?它没有。
听起来您的按钮属于这种UIButtonTypeRoundedRect
类型。下面的链接应该回答你的问题。
然而,我所做的只是不给它一个类型。
UIButton *myButton = [[UIButton alloc] init];
[myButton setBackgroundColor:[UIColor blueColor]];
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
虽然看起来不像那样花哨。
该按钮上的 buttonStyle 是什么?这将影响颜色设置的外观。您可能会尝试不同的按钮样式,直到找到一个看起来正确的样式。