zoukankan      html  css  js  c++  java
  • 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;

    }


    做一个顶天立地的男子,并且自信,健康微笑的生活下去!
  • 相关阅读:
    【Leetcode】92. Reverse Linked List II && 206. Reverse Linked List
    【Leetcode】91. Decode Ways
    记一次面经
    涨知识
    B-Tree 漫谈 (从二叉树到二叉搜索树到平衡树到红黑树到B树到B+树到B*树)
    涨知识
    HDU 1754 I Hate It 【线段树单点修改 维护区间最大值】
    POJ 1632 Vase collection【状态压缩+搜索】
    POJ 1011 Sticks 【DFS 剪枝】
    POJ 1088 滑雪 【记忆化搜索经典】
  • 原文地址:https://www.cnblogs.com/luoxiao1115/p/2819501.html
Copyright © 2011-2022 走看看