UI 常用方法总结之--- UIButton UIAlertView

UIButton : UIControl <NSCoding>

 

1.创建一个UIButton对象

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];

button.frame = CGRectMake(30, 140, 280, 30);

 

2.- (void)setTitle:(NSString *)title forState:(UIControlState)state;

设置按钮显示文字 

eg:[button setTitle:@"点击" forState:UIControlStateNormal];

 

3.showsTouchWhenHighlighted

点击的时候设置button的高亮

eg:button.showsTouchWhenHighlighted = YES;

 

4.- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

给按钮绑定一个方法,点击的时候 让某个特定的对象调用这个方法

参数1:执行方法的对象

参数2:要执行的方法(参数1的对象去执行)

 

参数3:按钮让绑定的对象调用方法,需要触发的事件

[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];

 

 

UIAlertView : UIView

 

1.创建一个UIAlertView对象

- (instancetype)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id /*<UIAlertViewDelegate>*/)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles

eg:UIAlertView *alertview = [[UIAlertView alloc]initWithTitle:@"提示" message:@"message" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@“确定1",@“确定2", nil];

 

2.- (void)show;

显示UIAlertView

eg:[alertview show];

 

 

3.- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;

点击了alertView上的哪个按钮

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值