@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
UIButton
- 常规创建方法
UIButton *btn = [[UIButton alloc]init];
UIButton *btn = [[UIButton alloc] initWithFrame:<#(CGRect)#>];
- 常用方法:UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//自定义按钮
UIButtonTypeSystem //系统风格
UIButtonTypeDetailDisclosure //它表明当前项目还有额外的细节和相关功能,点击后会在另一个表格或视图中呈现。
UIButtonTypeInfoLight,
UIButtonTypeInfoDark,// 它表明app的配置细节入口,新页面有时候出现在当前视图的背面
UIButtonTypeContactAdd,//蓝色加号(+)按钮,可以放在任何文字旁
- [button setTitle:@"BTN1" forState: UIControlStateNormal];//设置按钮的标题,forstate代表按钮状态,UIControlStateNormal(常态)、UIControlStateHighlighted(高亮)、UIControlStateSelected(选中),对于任何特定状态下的按钮,都可以设定该按钮该状态下的按钮标题。用setTitle 方法 设置即可
- [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];//设置指定状态下,标题文字颜色
- [button setImage:[UIImage imageNamed:@"a.png"] forState:UIControlStateNormal];//设置某状态下的按钮图片,[UIImage imageNamed:@"a.png"]表示以图片的名字获取图片
- [button setBackgroundImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateNormal];//设置背景图片
- [button setBackgroundColor:[UIColor whiteColor]];//设置背景色(不常用)
- button.titleLabel.font = [UIFont systemFontOfSize:12];//设置标题字体大小
- [ button addTarget:self action: @selector (pressed) forControlEvents:UIControlEventTouchUpInside];//添加触发事件及方法
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
时间: 2024-11-08 20:23:16