2
A
回答
-1
嘗試用這一個可能是它可以幫助你,
UIView *selectedBackgroundViewForCell = [UIView alloc]init];
[selectedBackgroundViewForCell setBackgroundColor:[UIColor grayColor]];
theCell.selectedBackgroundView = selectedBackgroundViewForCell;
(或)
cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SelectedCellBackground.png"]] autorelease];
2
所有單元選擇樣式通過設置單元格的selectedBackgroundView
財產實施。對於藍色和白色系統,這些是內置藍色和灰色梯度的視圖。將單元格選擇樣式設置爲藍色或灰色只是告訴單元格將其中一個視圖用作其選定的背景。
假設您已將所有單元格內容添加到內容視圖中,您仍然可以將這些樣式用於自定義單元格。
您可以創建自己的視圖(通常爲可拉伸圖像或自定義圖形視圖),並將其設置爲自定義效果的選定背景視圖。
當選中單元格時,它也會告訴其任何內容視圖子視圖(標籤等)突出顯示(如果可以)。您可以通過在任何標籤上設置highlightedTextColor
來控制此外觀。
您可以實現所有這些,而無需觸摸setSelected
。這一切都是由基礎實施完成的。
+0
投票?真?任何人都在意解釋爲什麼? – jrturton 2013-04-20 12:13:59
1
發現了完全適合由蘋果UITableViewCellSelectionStyleGray
實施UIColor
一個帖子:
UIColor* selectedColor = [UIColor colorWithRed:217.0/255.0
green:217.0/255.0
blue:217.0/255.0 alpha:1.0];
改變的事情上的選擇,只要你實現你的自定義UIButton
擴展中setSelected:(BOOL)selected
方法。這可以是這樣的:
- (void)setSelected:(BOOL)selected{
[super setSelected:selected];
if(selected){
// change things here on highlight
} else {
// change things here on unhighlight
NSLog(@"unselected");
}
}
進入這個模式,你應該將電池設置爲selected = YES
。
相關問題
- 1. UITableViewCellSelectionStyleGray的RGB值是多少?
- 2. removeEventListener是如何實現的?
- 3. MarshalByRefObject是如何實現的?
- 4. Spree.config是如何實現的?
- 5. pthread_join是如何實現的?
- 6. 「const」是如何實現的?
- 7. java.util.priorityqueue是如何實現的?
- 8. HttpSession是如何實現的?
- 9. nth_element是如何實現的?
- 10. pandas.json.dumps是如何實現的?
- 11. @private是如何實現的?
- 12. cudaMemset是如何實現的?
- 13. Python的difflib.find_longest_match是如何實現的?
- 14. Settings.app中的表是如何實現的?
- 15. python的fractions.limit_denominator是如何實現的?
- 16. assign @ property的setter是如何實現的?
- 17. 的dynamic_cast是如何實現的
- 18. WPF的DependencyObject是如何實現的?
- 19. 這個動畫是如何實現的
- 20. 這種影響是如何實現的?
- 21. <%= form_tag ... do%>是如何實現的?
- 22. Scala:Barrier同步是如何實現的?
- 23. Arrays.sort(Object [] a) - 它是如何實現的?
- 24. Objective-C類是如何實現的?
- 25. 條件變量是如何實現的?
- 26. .NET PointToClient函數是如何實現的?
- 27. 這個輸出是如何實現的?
- 28. std :: tuple是如何實現的?
- 29. C#字典是如何實現的? (C++)
- 30. 弱引用是如何實現的?
這並不顏色設置爲一樣'UITableViewCellSelectionStyleGray'並沒有顯示'UITableViewCell'怎麼設置成狀態選擇。 – 2015-05-08 10:33:41