嗨全部如何將TableView代碼應用於單元格的背景圖像和文本顏色白色不適用於tableview它只是爲cell給我iphone的解決方案。如何在tableview中應用單元格的背景圖像和文本顏色?
-3
A
回答
2
創建自定義Cell類
@interface CellView : UITableViewCell
{
UIImageView *img;
UILabel *lblTitle;
}
@property(nonatomic,retain)IBOutlet UIImageView *img;
@property(nonatomic,retain)IBOutlet UILabel *lbl;
@end
而且在t他執行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustCell *cell=(CustCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *arr=[[NSBundle mainBundle] loadNibNamed:@"CustCell" owner:self options:nil];
for (id idCell in arr){
if([idCell isKindOfClass:[UITableViewCell class]])
{
cell=(CustCell *) idCell;
break;
}
}
}
cell.lbl.text=[arrname objectAtIndex:indexPath.row];
cell.img.image=[UIImage imageNamed:@"logo.jpg"];
// Configure the cell.
return cell;
}
1
您可以添加一個子視圖到cell.contentView包含您的圖像的背景。 設置文字的顏色,你可以做
[cell.textLabel setTextColor: your_color];
0
//設置研究背景圖像
[cell setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Your Image"]]];
//設置文本顏色
[cell.textLabel setTextColor:[UIColor blueColor]];
相關問題
- 1. 在iOS7中更改tableview單元格的背景顏色
- 2. python docx設置表格單元格背景和文本顏色
- 3. 更改tableView中偶數單元格的背景顏色
- 4. Excel:使用rgb設置單元格和文本顏色的背景顏色
- 5. 使用的單元格背景顏色
- 6. 表格單元格的背景顏色
- 7. 在smartgwt中應用特定單元格的背景顏色ListGrid
- 8. 背景顏色背景圖像之間的圖層文本
- 9. 如何創建像分組tableview背景顏色的紋理背景(圖像調色板)顏色?
- 10. 如何更改Qt5中TableView頭的顏色(背景,文本)?
- 11. 如何用背景圖像爲背景顏色重新添加背景顏色?
- 12. 如何消除tableview中編輯單元格的灰色背景
- 13. 的TableView單元格顏色
- 14. 如何在VirtualTreeView中將單元格與背景圖像混合顏色?
- 15. 背景顏色在背景圖像
- 16. 如何自定義android中Toast的背景,背景顏色和文本顏色
- 17. JavaFx動態設置Tableview單元格背景顏色
- 18. 如何更改reStructuredText中表格單元格的背景顏色?
- 19. 如何更改表格中單擊單元格的單元格背景顏色?
- 20. 如何在Devexpress Grid中更改單元格的背景顏色?
- 21. 如何在ObjectListView中更改單元格的背景顏色?
- 22. 如何更改NSForm中的單個單元格背景顏色?
- 23. 如何更改windows.forms.datagrid中單個單元格的背景顏色?
- 24. 如何設置DataGridView中單個單元格的背景顏色?
- 25. 如何設置tableView的背景顏色
- 26. Excel VBA,匹配字體顏色和單元格背景顏色
- 27. 如何設置單元格背景顏色在jqgrid中的單元格值baced?
- 28. 將背景圖像和背景顏色對添加到元素
- 29. 如何使用java腳本更改表格中單元格的背景顏色
- 30. CSS:背景顏色的背景圖像