我將如何更改UITableView的顏色?或者改變一個單元格的顏色?或者更改頂部導航欄的顏色? (iOS)UITableView如何更改顏色?
1
A
回答
2
您可以更改單元格的顏色在UITableView的委託方法是這樣的:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (!cell) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:@"UITableViewCell"]autorelease];
}
}
//在這裏你可以去與任何顏色/你的背景改成你想要
//改變顏色:
[cell setBackgroundColor:[UIColor blackColor]];
//改變的細胞的背景圖像:
UIImage *theImage = [UIImage imageNamed:@"ximage.png"];
[[cell imageView] setImage:theImage];
}
0
要更改單元格的顏色,您需要創建自己的UITableViewCell的子類。而要改變導航欄的背景顏色,我相信這是
self.navigationItem.backgroundColor = [UIColor redColor];
感謝,
macintosh264
0
您可以通過backgroundView設置表和a的內容查看的的backgroundColor這樣做細胞。請參閱this以開始使用。導航欄可以通過繼承UINavigationBar並重寫drawRect方法來完成。
P.S:以上所有內容都是基本主題,教程遍佈整個Web和Stack Overflow本身。嘗試搜索並閱讀。
0
注意,從IOS3你不設置單元格背景顏色
- (UITableViewCell的*)的tableView:(UITableView的*)的tableView 的cellForRowAtIndexPath:(NSIndexPath *)indexPath
將其設置在
- (無效)tableVie女:(UITableView的*)的tableView willDisplayCell:(的UITableViewCell *)細胞forRowAtIndexPath:(NSIndexPath *)indexPath
這裏指出
相關問題
- 1. 如何更改UITableView邊框的顏色?
- 2. 自動更改UITableView顏色?
- 3. 更改UITableView標題色調顏色
- 4. 顏色更改爲標題中的UITableView
- 5. 更改UITableView標題的背景顏色
- 6. 更改UITableView節標題的顏色
- 7. 更改UITableView部分標題的顏色
- 8. UITableView - 更改節標題顏色
- 9. 突出顯示更改UITableView cell.detailTextLabel顏色
- 10. 僅更改UITableView的主體顏色或僅更改狀態欄顏色
- 11. 如何更改光標顏色而不更改文字顏色?
- 12. 如何更改sbt顏色?
- 13. 如何更改ActionBar顏色
- 14. 如何更改createCircularReveal()顏色?
- 15. 如何更改layer.border.top顏色?
- 16. 如何更改CircularFillableLoaders顏色?
- 17. 如何更改CCTexture2D顏色
- 18. UNITY - 如何更改顏色?
- 19. 如何更改ActionBar顏色?
- 20. 如何更改UITabBar顏色?
- 21. 如何更改ttk.Separator顏色
- 22. 如何更改JProgressBar顏色?
- 23. 如何更改顏色?
- 24. 如何更改顏色
- 25. 如何更改GroupStyle顏色?
- 26. 如何更改QIcon顏色?
- 27. raphael如何更改顏色
- 28. 如何更改JLabel顏色
- 29. 如何更改TabPanel顏色?
- 30. 如何更改索引UITableView中邊字母的顏色?
謝謝,但我將如何改變導航欄的顏色?我沒有將它添加到Interface Builder中;它是以編程方式創建的。 –
UINavigationController * myNavController; myNavController.navigationBar.tintColor = [UIColor redColor]; – 2011-09-22 01:33:27
正是我在找的東西。我只是把它放在我的應用程序delegate.m中,它工作得很完美。謝謝! –