我在我的tableViewCell
中加载了一些UIView
。其中一个属性是边框颜色。这些颜色存储在NSArray
,这是buttonColorArray
。我想设置他们在我的cellForRowAtIndexPath
这样的:当颜色来自NSArray时,如何在tableViewCell中设置多个UIView的边框颜色
ViewDidLoad
:
self.buttonColorArray = [[[NSArray alloc] initWithObjects:
[UIColor colorWithRed:250.0f/255.0f green:110.0f/255.0f blue:40.0f/255.0f alpha:1.0f],
[UIColor colorWithRed:77.0f/255.0f green:212.0f/255.0f blue:92.0f/255.0f alpha:1.0f],
[UIColor colorWithRed:255.0f/255.0f green:197.0f/255.0f blue:0.0f/255.0f alpha:1.0f],
[UIColor colorWithRed:59.0f/255.0f green:89.0f/255.0f blue:152.0f/255.0f alpha:1.0f],
[UIColor colorWithRed:84.0f/255.0f green:171.0f/255.0f blue:237.0f/255.0f alpha:1.0f], nil] autorelease];
cellForRowAtIndexPath
:
[Cell.expandedCellContainerView.layer setBorderColor:[self.buttonColorArray objectAtIndex:indexPath.row]];
但是我在这里得到一个警告。据我所知边框颜色总是被设置为.CGColor
。所以我加我的方法是这样的:
[Cell.expandedCellContainerView.layer setBorderColor:[self.buttonColorArray objectAtIndex:indexPath.row].CGColor];
但它不工作。 (这是工作,如果我只是在这里添加一个固定的颜色,而不是阵列)
我也尝试添加.CGColor
在我的buttonColorArray
。但它仍然不起作用。如果有人知道使用它的正确方法和理由,请与我分享。
很多预先感谢。