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上的哪個按鈕