我有一个UISearchBar,它有一个取消按钮(显示使用-(void)setShowsCancelButton:animated
).tintColor
为了获得一个灰色的搜索栏,我已经改变了这样的搜索栏:
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];
searchBar.tintColor = [UIColor colorWithWhite:0.8 alpha:1.0];
Run Code Online (Sandbox Code Playgroud)
这就是它现在的样子 - 注意取消按钮也是灰色的:http://twitpic.com/c0hte
有没有办法分别设置取消按钮的颜色,所以它看起来更像这样:http://twitpic.com/c0i6q
我在UITableView的单元格中添加了一个文本阴影,给它们一个蚀刻的外观:
cell.textLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1.000];
cell.textLabel.shadowColor = [UIColor whiteColor];
cell.textLabel.shadowOffset = CGSizeMake(0, 1);
Run Code Online (Sandbox Code Playgroud)
由于阴影颜色实际上是白色,当一行被选中并变为蓝色时,白色阴影变得非常明显并使文本看起来很难看.
有没有人知道如何在应用默认单元格选择样式之前删除阴影?
我试过了:
-tableView:willSelectRowAtIndexPath:
取消设置的阴影cell.textLabel.shadowColor = nil
,但这不按时上班-阴影未设置得到应用了蓝色选择样式之后.cell.selected
中tableView:cellForRowAtIndexPath:
设置的阴影之前,但这显然是行不通的,因为电池是不是一个选择后重绘.我也试过覆盖-tableView:willDisplayCell:forRowAtIndexPath:
委托方法,正如Kevin在下面提到的那样.从我输入的日志语句中,这个委托方法仅在绘制单元格之前调用 - 在触摸单元格时,它已经太晚了.这是我使用的代码
(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"in willDisplayCell");
if (cell.highlighted || cell.selected) {
NSLog(@"drawing highlighed or selected cell");
cell.textLabel.shadowColor = nil;
} else {
cell.textLabel.shadowColor = [UIColor whiteColor];
}
}
Run Code Online (Sandbox Code Playgroud)