添加UITableViewController下的纯代码按键
-(void)binge_addSendBtns {
// 设置按键位置的参数
CGFloat viewW = self.view.bounds.size.width;
UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, viewW, 200)];
// 设置 footerView
self.tableView.tableFooterView = footerView;
UIButton *sendMsgBtn = [[UIButton alloc]init];
[sendMsgBtn addTarget:self action:@selector(sendMsg) forControlEvents:UIControlEventTouchUpInside];
// 按键颜色
[sendMsgBtn setBackgroundColor:[UIColor colorWithRed:50.0/255 green:180.0/255 blue:50.0/255 alpha:1]];
// 按键文字颜色
[sendMsgBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
// 按键标题
[sendMsgBtn setTitle:@"发消息" forState:UIControlStateNormal];
// 按键位置
sendMsgBtn.frame = CGRectMake(20, 0, viewW - 40, 44);
// 圆角
sendMsgBtn.layer.cornerRadius = 10;
// 切除/覆盖多余的
sendMsgBtn.layer.masksToBounds = YES;
// [self.view addSubview:sendMsgBtn];
[footerView addSubview:sendMsgBtn];
}
- (void)viewDidLoad {
[super viewDidLoad];
//调用方法
[self binge_addSendBtns];
}
网友评论