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源代码下载:点我传送

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

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

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • IDEA创建springboot + mybatis项目全过程「建议收藏」

    IDEA创建springboot + mybatis项目全过程「建议收藏」鉴于隔很久再在IDEA新建springboot项目时,会出现对步骤不确定的情况,因此,写下这篇博客记录创建一个可运行的springboot+mybatis项目的全过程。步骤如下:1.打开IDEA2.File==>new==>project,如图:3.选择springInitializr==>右边的ProjectSDK我选的是我已经安…

    2022年6月24日
    55
  • java 根据“|”分割字符串需要使用“\\|” 双反斜杠做特殊处理

    java 根据“|”分割字符串需要使用“\\|” 双反斜杠做特殊处理java 根据“|”分割字符串需要使用“\\|” 双反斜杠做特殊处理

    2022年4月23日
    315
  • Java Web和Java后端开发的学习路线

    Java Web和Java后端开发的学习路线基础:比如计算机系统、算法、编译原理等等Web开发:主要是Web开发相关的内容,包括HTML/CSS/JS(前端页面)、Servlet/JSP(J2EE)以及Mysql(数据库)相关的知识。它们的学习顺序应该是从前到后,因此最先学习的应该是HTML/CSS/JS(前端页面),这部分内容你可以去上面的那个runoob网站上找。J2EE:你需要学习的是Servlet/JSP(J2EE)部分,…

    2022年7月8日
    24
  • clion永久激活码2021(注册激活)

    (clion永久激活码2021)2021最新分享一个能用的的激活码出来,希望能帮到需要激活的朋友。目前这个是能用的,但是用的人多了之后也会失效,会不定时更新的,大家持续关注此网站~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月26日
    1.2K
  • python postmessage_postmessage用法详解

    python postmessage_postmessage用法详解postmessage用法关于html5的PostMessage的用法总结大家都知道,网页之间传递数据可以使用ajax请求来完成,今天我总结下我学习的postMessage是如何完成跨页面请求数据的呢?首先,postMessage是html5新增的一个解决跨域的一个方法。那他是如何使用的呢?这里我把一个案例分享出来把。相关视频教程推荐:html视频教程看下面的代码:test.htmlonmessa…

    2022年7月13日
    14
  • processon激活成功教程版_杭州小木吉软件科技有限公司

    processon激活成功教程版_杭州小木吉软件科技有限公司processon.com-在线团队协作软件今天学到一个在线团队协作软件:www.processon.com免费在线作图,实时协作ProcessOn支持以下等等协同作业场景:流程图、思维导图、原型图、UML、网络拓扑图、组织结构图等等另外支持模板(可选)。以上就是关于“processon.com-在线团队协作软件(草巾冒小子)推荐”的全部内容。…

    2022年10月19日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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