一 要求效果
实现效果,在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;
}