objective-c - 如何制作带有白色文字的蓝色按钮?

标签 objective-c iphone uibutton background-color

// 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/

相关文章:

iphone - CGFloat 作为属性

iphone - 如何执行来自 iOS 应用程序的 URL 请求?

ios - 带圆角半径的渐变 UIButton 边框

objective-c - 为什么我不能在头文件中定义纯 C 函数?

ios - deleteRowsAtIndexPaths 不起作用但是 [self.tableView reloadData] 起作用

ios - 来自 native 应用程序的 Instagram API OAuth

iphone - MkPolygon : Display popup bubble on tap

iOS如何添加单选按钮

ios - 将快速添加方法包含到 UITableView 的方法

objective-c - 语法 : assign method's property value to sql command