【问题标题】:xcode custom cell opacity not working on iOS 4xcode 自定义单元格不透明度不适用于 iOS 4
【发布时间】:2012-09-17 11:51:59
【问题描述】:

我正在处理自定义单元格,当我在 iOS 5 模拟器上测试时一切正常,但是当我在 iOS 4 模拟器上检查时出现问题。单元格背景图像的不透明度不起作用

这是在 iOS 4 上

这是在 iOS 5 上,我希望它看起来像在 iOS 4 上

我使用的方法是

-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TabelCellEb.png"]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TabelCell.png"]];}

viewDidLoad 中为表格背景是

self.tableView.backgroundColor = [UIColor clearColor];
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TableBackground.png"]];

知道如何解决这个问题吗?

更新:这是我正在使用的单元格 BG 图像

它对其有影响,并且不透明度为 %30

更新2:

新图片

现在背景图像在替换为该代码后随着表格上下移动

self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TableBackground.png"]];

【问题讨论】:

    标签: iphone objective-c ios xcode


    【解决方案1】:

    我解决了这个问题,

    我删除了tableView willDisplayCell 方法并将此代码添加到tableView cellForRowAtIndexPath

    UIImage *cellImage = [UIImage imageNamed:@"TabelCellMu.png"];
    UIImageView *cellBackgroundImage = [[UIImageView alloc]initWithImage:cellImage];
    cell.backgroundView = cellBackgroundImage;
    cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TabelCell.png"]];
    

    在 iOS 4 和 5 中一切正常 :)

    【讨论】:

      猜你喜欢
      • 2022-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-27
      • 2020-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多