iOS tableView~尾部添加控件

来源:互联网 发布:高级数据库系统与实现 编辑:程序博客网 时间:2024/06/05 16:17

//联系人:石虎 QQ:1224614774 昵称:嗡嘛呢叭咪哄

/**

 注意:在cell的最后一行添加文案

*/

一、效果图:


二、代码实现

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

{

    //底部文案

    CGFloat bottomViewH = 30;

    UIView *bottomView = [[UIView alloc]initWithFrame:CGRectMake(0,self.view.bounds.size.height -80,OK_SCREEN_WIDTH, bottomViewH)];

    if (section ==0) {

        bottomView.backgroundColor = [UIColor clearColor];

    }else{

        bottomView.backgroundColor = OKColorRGBA(188,154,99,0.1);

    }

    [self.view addSubview:bottomView];

    

    //文案

    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0,8,0,0)];

    titleLabel.font = kGlobalFontSize_13;

    titleLabel.text = @"八方贵金属合作机构均有国家监管保障";

    titleLabel.textAlignment = NSTextAlignmentCenter;

    [titleLabel sizeToFit];

    titleLabel.ok_centerX = self.view.ok_centerX;

    titleLabel.textColor = kGlobalButtonYellow;

    [bottomView addSubview:titleLabel];

    

    //图片

    UIImageView *LeftImage = [[UIImageView alloc] initWithFrame:CGRectMake(titleLabel.mj_x-20,8, titleLabel.ok_height, titleLabel.ok_height)];

    LeftImage.image = [UIImage imageNamed:@"img_shield_shield"];

    [bottomView addSubview:LeftImage];

    

    return bottomView ;

}


谢谢!!!