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];//显示在页面上

 

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。