我将尝试使用
colorwithPatternImage
为tableviewcell
设置不同的backgroundColor
,但是效果与预期不符。文档中没有提到只能同时使用一种图案。例如,如果我有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"]];
所有三行都将是红色。就好像存在某种全局颜色被返回。
colorWithPatternImage
对于每次调用都返回kCGColorSpaceModelPattern 1
,无论传入的图片是什么。如果真的只有一个全局图案,则颜色应该是最后设置的那个,换句话说是蓝色。
这毫无意义。有没有人对苹果在这里做了什么有内部专业知识?
编辑 我甚至在完全不同的视图中使用了不同的图案,它仍然影响着其他视图的图案。我确信,虽然文档没有说明,但你一次只能使用一个UIColor图案。可悲。