Iphone UIColor colorWithPatternImage仅使用一个图像

Iphone UIColor colorWithPatternImage仅使用一个图像,iphone,uitableview,uicolor,Iphone,Uitableview,Uicolor,我试图给tableviewcell不同的backgroundColors添加colorwithPatternImage,但它没有按预期工作。文档中没有提到一次只能使用一种模式 假设我有3行,我将背景设置为: Cell1.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"red.png"]]; Cell2.backgroundColor = [UIColor colorWithPatternImage

我试图给
tableviewcell
不同的
backgroundColor
s添加
colorwithPatternImage
,但它没有按预期工作。文档中没有提到一次只能使用一种模式

假设我有3行,我将背景设置为:

Cell1.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"red.png"]];

Cell2.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"green.png"]];

Cell3.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"blue.png"]];
所有3行都是红色的。就好像有一些全局颜色正在返回

colorWithPatternImage
为每个调用返回
kCGColorSpaceModelPattern 1
,无论传入的是什么图像。如果一次只有一个全局图案是真的,那么颜色应该是最后一组,换句话说,蓝色

这毫无意义。有人对苹果在这里做什么有任何内部专业知识吗

编辑 我甚至在一个完全独立的视图中使用了不同的模式,它仍然会影响其他视图的模式。我确信,尽管文档中没有说明这一点,但一次只能使用一种UIColor图像模式。悲哀。

什么是Cell1?你在哪里(用什么方法)设置这些

我想说的是,你应该在家里做这一切

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

    static NSString *CellIdentifier = @"Cell";

    MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {      
      // create cell
    }

    // Set up the cell...

    // set up a background color
    if (something)
        cell.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"red.png"]];
    else (another)
        cell.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"green.png"]];
    else
        cell.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"blue.png"]];
}

据我所知,这不是或不再是真的。我这里有几个UITableViewCell,每个都有不同的背景图像,没有任何问题。

我就是用这种方法做的。因此,将返回一个单元格,以便表可以显示它。单元格[1-3]实际上都是开关中的case语句,