选定单元格的边框是否有可能以在Objective-C突出的UITableViewController
的边界的选定单元格?突出显示的UITableView
3
A
回答
2
你可以尝试做一个自定义的UIView /的UIImageView的选择与setSelectedBackgroundView:
这里是一个示例代码我在自定义tableviewcell使用自定义的梯度:
UIView *selctionView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)] autorelease];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = selctionView.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blueColor] CGColor], (id)[[UIColor redColor] CGColor], nil];
[selctionView.layer insertSublayer:gradient atIndex:0];
[self setSelectedBackgroundView:selctionView];
编辑:
我发现你也可以使用下面的方法:
[test.layer setBorderColor: [[UIColor redColor] CGColor]];
[test.layer setBorderWidth: 1.0];
为图层。
一定要导入QuartzCore.h
否则整个实现代码如下:
[tableViewController.tableView setSeparatorColor:[UIColor redColor]];
0
这是非常简单的,因为OS 3.0刚刚成立的willDisplayCell方法的单元格的背景颜色。您不能在cellForRowAtIndexPath中设置颜色。
这同时适用于平原和分组方式:
代码:
- (无效)的tableView:(UITableView的*)的tableView willDisplayCell:(的UITableViewCell *)细胞forRowAtIndexPath:(NSIndexPath *)indexPath cell.backgroundColor = [UIColor redColor]; }
P.S:这里willDisplayCell文件摘录:
"A table view sends this message to its delegate just before it uses cell to draw a row, thereby permitting the delegate to customize the cell object before it is displayed. This method gives the delegate a chance to override state-based properties set earlier by the table view, such as selection and background color. After the delegate returns, the table view sets only the alpha and frame properties, and then only when animating rows as they slide in or out."
我发现这个职位从colionel此信息。谢谢他!
相关问题
- 1. 使Swift UITableView的单元格在突出显示时突出显示
- 2. 突出显示UITableView没有选择
- 3. 突出显示更改UITableView cell.detailTextLabel颜色
- 4. 显示UITableView溢出?
- 5. 使用UISearchBar突出显示UITableView中的搜索文本
- 6. 如何突出显示UITableView中的一行
- 7. 嵌套在ContainerView中的UITableView不突出显示
- 8. Algolia - 格式突出显示的文本只显示突出显示的部分
- 9. getSelection突出显示
- 10. 突出显示RecyclerView
- 11. NSTextView突出显示
- 12. Solr - 突出显示
- 13. 突出显示VIM
- 14. 突出div.slideToggle显示
- 15. 突出显示PHP
- 16. UITableView:突出显示最后一个单元格,但其他单元格也突出显示
- 17. Lucene突出显示:突出显示一个令牌部分
- 18. 突出显示cursorcolumn覆盖任何现有突出显示
- 19. VIM不突出显示PHP文件,突出显示其他人
- 20. CGPDFDocument中的突出显示
- 21. 突出显示的jqGrid树
- 22. 突出显示JTextArea的行
- 23. Xcode UITableView行选中时未突出显示
- 24. UITableView项目被突出显示,然后取消选择 - Swift
- 25. UITableView - 突出显示所选单元格[iOS]
- 26. 以编程方式突出显示UITableView单元格
- 27. 在UITableView单元格中突出显示搜索结果iOS Swift
- 28. iOS - UIButton显示突出显示颜色
- 29. 的UITableView显示
- 30. WPF突出显示项目
嘿谢谢。这是我的实际要求:我使用的是一个splitviewcontroller。在这里,当我在rootview控制器中选择特定的单元格时,需要更改相应单元格的4个边框颜色。 – Tinku
没问题,你也可以选择一个动画(例如将渐变从“黑色变为浅色”变为“光变为黑色”),看起来非常棒,我只在选择时再次选择一些缺陷。 – Justin
是的,那真的很好。如何更改选定的单元格textcolor而不影响其他单元格? – Tinku