小秋的家

          home

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            1 Posts :: 91 Stories :: 17 Comments :: 0 Trackbacks
          最好的方式應(yīng)該是通過cell.backgroundView來改變cell的背景。按照文檔說明,backgroundView始終處于 cell的最下層,所以,將cell里的其它subview背景設(shè)為[UIColor clearColor],以cell.backgroundView作為統(tǒng)一的背景,應(yīng)該是最好的方式。
          - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
           
          static NSString *cellIdentifier = @"CellIdentifier";
           
          UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
          if (!cell)
          {
          cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier] autorelease];
          }
           
          cell.textLabel.text = [NSString stringWithFormat:@"Line: %d", indexPath.row];
          cell.textLabel.backgroundColor = [UIColor clearColor];
           
          UIView *backgrdView = [[UIView alloc] initWithFrame:cell.frame];
          backgrdView.backgroundColor = [UIColor blueColor];
          cell.backgroundView = backgrdView;
          [backgrdView release];
           
          return cell;
          }
          posted on 2011-10-24 11:28 棋劍小秋 閱讀(3375) 評論(0)  編輯  收藏 所屬分類: iPhone
          主站蜘蛛池模板: 波密县| 南昌市| 河源市| 达拉特旗| 京山县| 墨脱县| 汽车| 灵寿县| 共和县| 珠海市| 丰县| 大港区| 桑日县| 双鸭山市| 汶川县| 巴里| 渝中区| 安国市| 呼和浩特市| 西宁市| 绥宁县| 荆州市| 中牟县| 桐乡市| 中卫市| 南澳县| 凤城市| 观塘区| 手游| 宾川县| 新余市| 天柱县| 虞城县| 台北县| 木里| 临城县| 鹿邑县| 南川市| 昌江| 洪湖市| 临桂县|