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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • jenkins+SVN配置「建议收藏」

    jenkins+SVN配置「建议收藏」开发项目,版本控制必不可少,我用的版本控制软件为SVN,那么如何把jenkins和SVN结合,使得SVN源码一有上传更新,jenkins就马上构建项目呢?下面说一下配置过程1)首先要在jenkins中添加svn的用户名和密码:打开“Credentials”界面进行添加,如下图2)配置项目工作空间3)配置项目:源码管理选择SVN,如下图:4)配置项目:设置构建触发器…

    2022年9月12日
    0
  • 计算机病毒对消息钩子的利用与对抗

    计算机病毒对消息钩子的利用与对抗一、消息钩子的概念    1、基本概念   Windows应用程序是基于消息驱动的,任何线程只要注册窗口类都会有一个消息队列用于接收用户输入的消息和系统消息。为了拦截消息,Windows提出了钩子的概念。钩子(Hook)是Windows消息处理机制中的一个监视点,钩子提供一个回调函数。当在某个程序中安装钩子后,它将监视该程序的消息,在指定消息还没到达窗口之前钩子程序先捕获这个消息。这样就有

    2022年7月26日
    8
  • C++异常处理建议收藏

    一C++异常处理机制异常处理基本思想:执行一个函数的过程中发现异常,可以不用再本函数内立即进行处理,而是抛出该异常,让函数的调用者直接或间接的处理这个问题。C++异常处理进制由三个模块组成:tr

    2021年12月19日
    40
  • 玩客云 青龙面板_青龙京东签到

    玩客云 青龙面板_青龙京东签到玩客云安装青龙面板实现京东签到薅羊毛

    2022年9月18日
    0
  • 〖EXP〗NSA MS17010永恒之蓝漏洞一键工具「建议收藏」

    〖EXP〗NSA MS17010永恒之蓝漏洞一键工具「建议收藏」漏洞简介永恒之蓝是指2017年4月14日晚,黑客团体ShadowBrokers(影子经纪人)公布一大批网络攻击工具,其中包含“永恒之蓝”工具,“永恒之蓝”利用Windows系统的SMB漏洞可以获取系统最高权限。5月12日,不法分子通过改造“永恒之蓝”制作了wannacry勒索病毒,英国、俄罗斯、整个欧洲以及中国国内多个高校校内网、大型企业内网和政府机构专网中招,被勒索支付高额赎金才能解密恢复文件。漏洞检测无损检测,不会对目标造成任何危害,大家无需担心Ladon192.168.1.8MS1701

    2022年6月3日
    159
  • navicate15 mysql激活码【在线注册码/序列号/破解码】

    navicate15 mysql激活码【在线注册码/序列号/破解码】,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月19日
    45

发表回复

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

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