UIButton *btnMy=[[UIButton alloc] initWithFrame:CGRectMake(0,0,768,40)];
[btnMy setBackgroundColor:[UIColor redColor]];
[self.view addSubview:btnMy];
[btnMy setBackgroundColor:[UIColor redColor]];
[self.view addSubview:btnMy];
本文介绍如何使用UIButton并设置其背景颜色为红色。通过初始化UIButton并指定frame大小,然后使用setBackgroundColor方法来改变按钮的颜色。

被折叠的 条评论
为什么被折叠?