首页 > 代码库 > ios 控件 UIButton

ios 控件 UIButton


- (void)setTitle:(NSString *)title forState:(UIControlState)state;//设置标题
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;//设置标题颜色
- (void)setTitleShadowColor:(UIColor *)color forState:(UIControlState)state;//设置标题阴影
- (void)setImage:(UIImage *)image forState:(UIControlState)state;//设置图片
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state;//设置图片背景
 
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(100, 150, 60, 40);//设置按钮位置大小
[button setTitle:@"Normal" forState:UIControlStateNormal];//设置常规下按钮的标题

 

[button setTitle:@"Highlight" forState:UIControlStateHighlighted];//设置高亮状态下的标题
[button addTarget:self action:@selector(didButtonClicked)forControlEvents:UIControlEventTouchUpInside];//设置按钮的点击事件

[self.view addSubview:button];//显示在页面上

 

 

ios 控件 UIButton