選定單元格的邊框是否有可能以在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. Solr突出顯示 - 需要突出顯示的短語
- 6. 如何突出顯示UITableView中的一行
- 7. 使用UISearchBar突出顯示UITableView中的搜索文本
- 8. 嵌套在ContainerView中的UITableView不突出顯示
- 9. Algolia - 格式突出顯示的文本只顯示突出顯示的部分
- 10. getSelection突出顯示
- 11. 突出顯示PHP
- 12. 突出顯示CalendarView
- 13. WPF突出顯示
- 14. Android:TextView突出顯示
- 15. 突出顯示RecyclerView
- 16. Solr - 突出顯示
- 17. 突出顯示div
- 18. NSTextView突出顯示
- 19. 突出顯示openui5
- 20. 突出div.slideToggle顯示
- 21. 突出顯示VIM
- 22. UITableView:突出顯示最後一個單元格,但其他單元格也突出顯示
- 23. C#標籤突出顯示並刪除突出顯示
- 24. 突出顯示cursorcolumn覆蓋任何現有突出顯示
- 25. jquery突出顯示和不突出顯示錶行
- 26. VIM不突出顯示PHP文件,突出顯示其他人
- 27. jquery突出顯示一個鏈接或刪除突出顯示
- 28. Lucene突出顯示:突出顯示一個令牌部分
- 29. 突出顯示JTextArea的行
- 30. CGPDFDocument中的突出顯示
嘿謝謝。這是我的實際要求:我使用的是一個splitviewcontroller。在這裏,當我在rootview控制器中選擇特定的單元格時,需要更改相應單元格的4個邊框顏色。 – Tinku
沒問題,你也可以選擇一個動畫(例如將漸變從「黑色變爲淺色」變爲「光變爲黑色」),看起來非常棒,我只在選擇時再次選擇一些缺陷。 – Justin
是的,那真的很好。如何更改選定的單元格textcolor而不影響其他單元格? – Tinku