UIButton的简单使用
UIButton 是 UIView 的一个重要的子类
UIButton 的主要作用是拦截事件和动作消息发送到目标对象
UIButton *myBtn = [UIButton buttonWithType:UIButtonTypeCustom];
myBtn.frame = CGRectMake(100, 100, 100, 100);
[myBtn setTitle:@"按钮" forState:UIControlStateNormal];
[self.window addSubview:myBtn];
[myBtn addTarget:self action:@selector(myBtnAction:) forControlEvents:UIControlEventTouchUpInside];
-(void)myBtnAction:(UIButton *)sender{
}
bringSubviewToFront : 把指定的子视图移动到最前面
[superview bringSubviewToFront: redView];
sendSubViewBack : 把指定的子视图移动到最后面
[superview sendSubViewBack: redView];
exchangeSubviewAtlndex : withSubviewAtlndex: 交换两个指定索引位置的子视图
[superview exchangeSubviewAtlndex: 0 withSubviewAtlndex:2];
removeFromSuperview : 把子视图从父视图上移除
[redView removeFromSuperview];