码迷,mamicode.com
首页 > 移动开发 > 详细

IOS UITableView 底部添加按钮

时间:2015-04-08 01:23:40      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

一 要求效果

实现效果,在UITableView最底部添加提交按钮.

可以通过UITableView tableFooterView 实现

// accessory view below content. default is nil. not to be confused with section footer
@property (nonatomic, retain) UIView *tableFooterView;



二 代码实现

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    //1.添加底部按钮
    [self addFooterButton];
}



/**
 *  添加底部按钮
 */
-(void)addFooterButton
{
    //1.初始化Button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    //2.设置文字和文字颜色
    [button setTitle:@"完成诊断" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    //3.设置圆角幅度
    button.layer.cornerRadius = 10.0;
    button.layer.borderWidth = 1.0;
    
    //4.设置frame
    button.frame = CGRectMake(0, 100, 20, 44);
    
    //5.设置背景色
    button.backgroundColor = GreenColor;
    
    //6.设置触发事件
    //省略
    
    //7.添加到tableView tableFooterView中
    self.tableView.tableFooterView = button;
}


三 效果图

技术分享


IOS UITableView 底部添加按钮

标签:

原文地址:http://my.oschina.net/u/1032974/blog/397125

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!