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


相关推荐

  • kthreaddi挖矿病毒

    kthreaddi挖矿病毒今天上服务器一查看cpu被占满了,使用了top命令一看,好家伙看到kthreaddi进程占用cpu300%老子气坏了,没碰见过,什么是kthreaddi白百度了一圈,原来【kthreaddi】是挖矿病毒不断的写入定时任务执行操作先是top命令查占用进程PID29221直接杀死但是过一段时间又会自动的建立进程使用查看定时任务命令crontab-e果然有一条定时任务,更加可气的是找不到这个文件解决办法:删除这条命名,然后又top命名kill-9PID杀死进…

    2022年5月10日
    61
  • c++开发面试问题(java面试app)

    面试智力题1、25皮马,5个赛道,求经过几场比赛,可以得到跑得最快的5皮马1)先把25皮马分成5组,分别每组进行比赛:(5场)A1A2A3A4A5、B1B2B3B4B5、C1C2C3C4C5、D1D2D3D4D5、E1E2E3E4E5。假设每组比赛后,结果如上所示。2)把每组最快的马拿出来进行比赛:(1场)A1B1…

    2022年4月10日
    43
  • 我为什么放弃Go语言

    我为什么放弃Go语言我为什么放弃Go语言?有好几次,当我想起来的时候,总是会问自己:这个决定是正确的吗?是明智和理性的吗?其实我一直在认真思考这个问题。开门见山地说,我当初放弃Go语言,就是因为两个“不爽”:第一,对Go语言本身不爽;第二,对Go语言社区里的某些人不爽。毫无疑问,这是非常主观的结论,但是我有足够详实的客观的论据。

    2022年6月30日
    22
  • C++生产和使用的临时对象

    C++生产和使用的临时对象

    2022年1月5日
    58
  • php面试常问方法汇总

    php面试常问方法汇总

    2022年2月15日
    40
  • android 测试用例模板下载,app测试用例模板.doc

    android 测试用例模板下载,app测试用例模板.docapp测试用例模板APP基本测试用例个人首页1.我的页面2.个人信息页面3.个性标签页面4.TA的页面消息页面消息页面发布商品和图片发布商品分享图片买买买页面买买买页面一级分类页面买手热荐品类二级分类页面侧边栏页面购物车页面我的钱包页面一、编号条件步骤预期结果实际结果1打开我的页面?出现我的信息(头像、昵称、签名、关注数、粉丝数、入手、出手)、中部出现切换我发表的与我喜欢的tab、下部列表出现内容…

    2022年7月17日
    13

发表回复

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

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