• UITableView 自定义cell 方法


    // 自定义 cell

    - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


        NSString *identifier = @"Cell";

        

        UITableViewCell *cell = [tableView  dequeueReusableCellWithIdentifier:identifier];


        if (cell == nil) {

            

            cell = [[[UITableViewCell  alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease] ;

            

            //自定义 cell的背景

            UIImageView *backImageView = [[UIImageView  alloc] initWithFrame:CGRectMake(0, 0, cell.width, cell.height)];

            [backImageView setImage:[UIImage imageNamed:@"tck_on3.png"]];

            backImageView.tag = 201;

            

            cell.selectedBackgroundView = backImageView;

            [backImageView  release];

            

            // 自定义评分Label

            UILabel *RatingLabel = [[UILabel  alloc] initWithFrame:CGRectMake(160, 0, 40, cell.height)];

            RatingLabel.text = @"";

            RatingLabel.textColor = [UIColor  whiteColor];

            RatingLabel.backgroundColor = [UIColor  clearColor];

            RatingLabel.font = [UIFont systemFontOfSize:14];

            RatingLabel.tag = 202;

            

            [cell.contentView  addSubview:RatingLabel];

            [RatingLabel  release];

            

        }

        

        // 获得评分 label

        UILabel *label = (UILabel *) [self  viewWithTag:202];

        label.text = [[self.data  objectAtIndex:indexPath.rowobjectForKey:@"rating"];

        

        

        // 电影名称

        cell.textLabel.text = [[self.data  objectAtIndex:indexPath.rowobjectForKey:@"title"];

        cell.textLabel.textColor = [UIColor  whiteColor];

        cell.textLabel.font = [UIFont systemFontOfSize:14];

        cell.textLabel.highlightedTextColor = [UIColor blackColor];

        

        return cell;

    }


    做一个顶天立地的男子,并且自信,健康微笑的生活下去!
  • 相关阅读:
    腾讯之困,QQ与微信各有各的烦恼
    Attribute(一)——提前定义特性
    假设有来生
    codeforces248(div1) B Nanami's Digital Board
    驳斥苹果“诊断后门论”,声援扎德尔斯基
    python批量下载色影无忌和蜂鸟的图片 爬虫小应用
    建筑建模学习笔记2——3DMax房屋框架建模
    【大话QT之十六】使用ctkPluginFramework插件系统构建项目实战
    javaObject类
    java基本类型和String之间的转换
  • 原文地址:https://www.cnblogs.com/luoxiao1115/p/2819501.html
Copyright © 2020-2023  润新知