美文网首页iOS开发代码段IOS开发资料大全
添加UITableViewController下的纯代码按键

添加UITableViewController下的纯代码按键

作者: 许威彬 | 来源:发表于2016-10-18 17:52 被阅读28次

添加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];
}

相关文章

网友评论

    本文标题:添加UITableViewController下的纯代码按键

    本文链接:https://www.haomeiwen.com/subject/zpstuttx.html