如何更改多选复选标记的颜色?
我尝试[cell setSelectionStyle:UITableViewCellSelectionStyleGray];
了这种- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
方法。
但这没有效果。
我是否限于文档中定义的UITableViewCellSelectionStyle
蓝色和灰色?
谢谢
请注意,在iOS 7中,使用
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
将无法正常工作,因为在iOS 7中,即使您传递了上面的常量,该颜色现在还是灰色的。看:
因此,可以使用此方法在-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath方法中更改颜色。
UIView *cellBg = [[UIView alloc] init];
cellBg.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // this RGB value for blue color
cellBg.layer.masksToBounds = YES;
Cell.selectedBackgroundView = cellBg;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句