iOS UITableView的Section Footer加入button「建议收藏」

iOS UITableView的Section Footer加入button

大家好,又见面了,我是全栈君。

郝萌主倾心贡献,尊重作者的劳动成果。请勿转载。

假设文章对您有所帮助,欢迎给作者捐赠。支持郝萌主,捐赠数额任意。重在心意^_^ 

我要捐赠: 点击捐赠

Cocos2d-X源代码下载:点我传送

在处理UITableView表格时,我们希望在View底部加入button。

用户拖动UITableView时button能尾随移动。

如题。实现例如以下界面:

iOS UITableView的Section Footer加入button「建议收藏」


- (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;
    }
}

郝萌主倾心贡献。尊重作者的劳动成果,请勿转载。

假设文章对您有所帮助,欢迎给作者捐赠,支持郝萌主。捐赠数额任意,重在心意^_^ 

我要捐赠: 点击捐赠

Cocos2d-X源代码下载:点我传送

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/116599.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • LVS基本配置

    LVS基本配置LVS说明【Linux操作系统核心空间中、一般采用DR构建集群】小结:{Ipvsadm:管理集群服务的命令行工具、Ipvs:内核模块/代码;三种负载均衡模式:【NAT:修改IP、双网卡,RIP指向DIP内网网关、任意操作系统】、【DR直接路由:一个网卡、配置别名、DIP和RIP在同一网关上、修改MAC地址】、【TUP隧道:封装IP报文,异地服务连接】} LVS主要组成部分为:  负

  • yum卸载重装[通俗易懂]

    yum卸载重装[通俗易懂]莫名原因(之前操作不小心删除了某相关文件)导致虚拟机的yum使用不了,在重新安装之前需要卸载原来的相关数据1.删除/usr/share目录下的yum-cli、yum-pluginrm-rfyum-cli/yum-plugins/2.清理与yum相关的文件rpm-qa|grepyumrpm-eyum-3.4.3-161.el7.centos.noarch…

  • Python 深入浅出 – PyPDF2 处理 PDF 文件

    Python 深入浅出 – PyPDF2 处理 PDF 文件实际应用中,可能会涉及处理pdf文件,PyPDF2就是这样一个库,使用它可以轻松的处理pdf文件,它提供了读,割,合并,文件转换等多种操作。文档地址:http://pythonhosted.org/PyPDF2/PyPDF2安装PyCharm安装:File->DefaultSettings->ProjectInterpreterPdfFileR

  • c语言移位操作

    c语言移位操作

    2021年12月17日
  • 第一范式、第二范式、第三范式[通俗易懂]

    第一范式、第二范式、第三范式[通俗易懂]范式:英文名称是NormalForm,它是英国人E.F.Codd(关系数据库的老祖宗)在上个世纪70年代提出关系数据库模型后总结出来的,范式是关系数据库理论的基础,也是我们在设计数据库结构过程中

  • socket粘包解决方案_socket 传输文件

    socket粘包解决方案_socket 传输文件一 .两个简单概念长连接与短连接:1.长连接   Client方与Server方先建立通讯连接,连接建立后不断开, 然后再进行报文发送和接收。2.短连接   Client方与Server每进行一次报文收发交易时才进行通讯连接,交易完毕后立即断开连接。此种方式常用于一点对多点通讯,比如多个Client连接一个Server.二 ….

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号