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(转)的更多相关文章
随机推荐
- python3-开发面试题(python)6.24基础篇(3)
1.用一行代码实现数值交换: a = 1 b = 2 a,b=b,a 2.Python3和Python2中 int 和 long的区别? long整数类型被Python3废弃,统一使用int ...
- 使用IDEA创建package
1)使用IDEA创建java工程 什么也不选,直接点击Next 无脑继续下一步 点击“Finish”完成工程的创建. 2)在使用IDEA创建了工程之后,首先选中“src”文件夹,然后 紧接着输入包名 ...
- 今天升级Xcode 7.0 bata发现网络访问失败。
今天升级Xcode 7.0 bata发现网络访问失败.输出错误信息 The resource could not be loaded because the App Transport Securit ...
- struts-2-spring-2-jpa-ajax
http://struts.apache.org/docs/struts-2-spring-2-jpa-ajax.html
- 阿里p6面试
电话面试: 第一次面试关注的问题,1)java基础: jvm 内存回收,垃圾回收基本原理,Java并发包的线程池,Java8的新特性.nio 堆排序.conrenthashmap , concurre ...
- cocos2dx -lua 面向对象-转
转自:http://www.himigame.com/lua-game/1282.html 上一篇中,向童鞋们介绍了如何自定义类binding到Lua中供给使用的教程,那么本篇将介绍利用OOP思想在在 ...
- Docker时间和宿主同步
通过date命令查看时间 查看主机时间 [root@localhost ~]# date 2016年 07月 27日 星期三 22:42:44 CST 查看容器时间 root@b43340ecf5ef ...
- Docker实践3: Docker常用命令(未完)
查看容器及运行进程 docker ps 查看容器内部信息 docker inspect container_id 进入容器 docker attach container_id 退出容器 docker ...
- flask-compress的使用方法以及对应的http头Vary、Content-Encoding的意思
参考:https://github.com/shengulong/flask-compress 1.Content-Encoding是HTTP协议的响应报文头,一般形式如:Content-Encodi ...
- ubuntu_software_install
1.atom PPA安装 命令行上依次输入即可完成安装: sudo add-apt-repository ppa:webupd8team/atom sudo apt-get update sudo a ...