UITabelViewFootView(转)
在处理UITableView表格时,我们希望在View底部添加按钮。
用户拖动UITableView时按钮能跟随移动。
如题,实现如下界面:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section >= kSetSetting) {
return 80;
}
else{
return 2;
}
} - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if (section >= kSetSetting)
{
UIView *footerView = [[UIView alloc] init];
footerView.userInteractionEnabled = YES;
footerView.backgroundColor = [UIColor clearColor]; UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
[loginButton.layer setMasksToBounds:YES];
[loginButton.layer setCornerRadius:5.0];
[loginButton setBackgroundColor:[UIColor brownColor]];
[loginButton setTitle:@登陆 forState:UIControlStateNormal];
[loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[loginButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
[loginButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[loginButton addTarget:self action:@selector(loginBtnClick:) forControlEvents:UIControlEventTouchUpInside];
//[footerView addSubview:btnExit]; [footerView addSubview:loginButton]; UIButton *registerButton = [UIButton buttonWithType:UIButtonTypeSystem];
[registerButton.layer setMasksToBounds:YES];
[registerButton.layer setCornerRadius:5.0];
[registerButton setBackgroundColor:[UIColor brownColor]];
[registerButton setTitle:@注册 forState:UIControlStateNormal];
[registerButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[registerButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
[registerButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[registerButton addTarget:self action:@selector(registerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[footerView addSubview:registerButton]; NSDictionary *constraintsView = NSDictionaryOfVariableBindings(loginButton,registerButton); [footerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@V:|-15-[loginButton]-15-| options:0 metrics:nil views:constraintsView ]];
[footerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@|-20-[loginButton] options:0 metrics:nil views:constraintsView ]]; [footerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@V:|-15-[registerButton(==loginButton)]-15-| options:0 metrics:nil views:constraintsView ]];
[footerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@H:[loginButton]-30-[registerButton(==loginButton)]-20-| options:0 metrics:nil views:constraintsView]]; return footerView;
}
else
{
return nil;
}
}
原文章地址:http://www.2cto.com/kf/201506/407035.html
UITabelViewFootView(转)的更多相关文章
随机推荐
- 配置.net程序集搜索路径
默认情况下,.net程序对外部程序集dll的搜索路径是exe文件所在的目录,虽然这种方式没有什么太多不好的地方,但是当我们引用外部程序集较多的时候显得非常杂乱.一种比较常用的解决方式是通过配置在app ...
- c# 播放mp3
转载:http://www.cnblogs.com/igrl/archive/2010/03/29/1699975.html /// <summary> /// 播放MP3文件 /// & ...
- shell基本计算、逻辑运算、位运算详解
转:http://blog.chinaunix.net/uid-8504518-id-3918531.html Shell 提供大量的基本运算操作,在脚本中非常有用.Shell 对您提供的算术表达式求 ...
- vim 代码注释插件
参考: 1.http://www.vim.org/scripts/script.php?script_id=1218 2.http://www.dutor.net/index.php/2010/05/ ...
- fl2440 platform总线led字符设备驱动
首先需要知道的是,设备跟驱动是分开的.设备通过struct device来定义,也可以自己将结构体封装到自己定义的device结构体中: 例如:struct platform_device: 在inc ...
- Python数据整合与数据准备-BigGorilla应用
一.前言 要应用BigGorilla框架对应数据进行数据的处理与匹配,那么首先要下载Anaconda安装,下载地址:https://www.continuum.io/downloads Anacond ...
- Druid和Spark对比
Druid和Spark对比 不是Spark专家, 如果描绘有错误, 请通过邮件列表或者其他方式告知我们 Spark实现弹性的分布式数据集概念的计算集群系统, 可以看做商业分析平台. RDDs能复用持久 ...
- 报错:numRecords must not be negative
报错的原因:删除已经使用过的kafka topic,然后新建同名topic 解决方法:把topic名字换一下 (有其他更好的解决方法,可以不修改topic名)
- RocketMQ之连接以及连接缓存
发现rabbitmq有一个ConnectionFactory.发现rocketmq好像没这个东西.按道理来说如果每次发送消息都新建一条连接肯定是不可能的. ps:其实之所以是有上面的疑问是因为数据库连 ...
- 使用Google-Authenticator加强serverSSH登录
对于须要特殊加密的人群,我这里给出对应的方法来进行谷歌式加密. 过程例如以下: 准备: 首先在你的手机上准备好client(自己百度下载) 接下来依照命令做: date 查看系统时间 da ...