我是Xcode新手,目前正在構建我的第一個應用程序。我搜索了很長時間,很難嘗試找到適當的教程,但我找不到一個。我正在尋找一種方法能夠在我的UITableViewController中插入自定義背景。我可以改變顏色,但就是這樣。我期望做的是將我的PNG圖像放置在我創建的靜態單元格後面,並將不透明度放在這些單元格上,以便自定義圖像通過。有人可以給我一個方法來做到這一點,無論是通過IB(故事板)或通過編碼。非常感激!!提前致謝!如何將自定義圖像添加到Xcode中的UITableviewController?
-2
A
回答
2
我覺得更輕鬆,正確的方法是:
[tableView setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourimage.png"]]];
您可以在viewDidLoad中的代碼,使其工作。
0
細胞的背景:在willDisplayCell:atIndexPath:
方法
UIImageView *cellImageView = [[UIImageView alloc] initWithImage:[UIImageimageNamed:@"image.png"]]];
CGRect Frame = cell.backgroundView.bounds;
cellImageView.frame = newFrame;
[cell.backgroundView addSubview:cellImageView];
的實現代碼如下背景做到這一點,爲此在viewDidLoad:
方法
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"BackgroundPattern.png"]];
0
UIImageView *ivwCellBackground=[[UIImageView alloc]init];
[ivwCellBackground setImage:[UIImage imageNamed:CELL_BACKGROUNGIMAGE]];
cell.backgroundColor=[UIColor clearColor];
[cell setBackgroundView:ivwCellBackground];
[ivwCellBackground release];
ivwCellBackground=nil;
相關問題
- 1. 將圖像添加到自定義AlertDialog
- 2. 如何將自定義UIButton添加到XCode中的nib文件?
- 3. 如何將圖像添加到自定義的WiX對話框?
- 4. android:如何將自定義圖像添加到小部件?
- 5. 如何使用Branch.io將自定義圖像添加到鏈接?
- 6. 如何將選定的UITableViewController值添加到先前的UITableViewController?
- 7. 如何將圖像添加到Xcode中的C++項目中
- 8. 如何將自定義圖像按鈕添加到iPhone中的UINavigationBar sdk
- 9. 如何將自定義圖像添加到Mapview Swift ios中的註釋?
- 10. 如何將自定義圖像字段添加到Magento中的類別?
- 11. 如何將圖像添加到XCode的界面生成器中?
- 12. 將圖像添加到自定義列表視圖
- 13. 將自定義圖像添加到日曆視圖
- 14. 將editText添加到自定義視圖
- 15. 將視圖添加到自定義ViewGroup
- 16. 圖像未添加到項目添加到自定義列表
- 17. 如何將iOS VoiceOver轉子添加到自定義視圖中?
- 18. 如何將自定義視圖添加到JSQMessagesViewController中
- 19. 無法將圖像添加到我的自定義webhook
- 20. 如何在Android中的自定義ListView中添加圖像?
- 21. 如何將自定義標記圖標添加到Google地圖?
- 22. 如何將自定義圖例添加到用ggplot繪圖?
- 23. 如何將自定義圖標添加到谷歌地圖v3
- 24. 如何在CustomBox中添加自定義加載圖像?
- 25. 如何在Outlook自定義列中添加位圖圖像
- 26. android如何將自定義水平滾動視圖添加到圖像列表
- 27. 如何動態添加自定義文本輸入到圖像
- 28. 如何將uitoolbar添加到uitableviewcontroller?
- 29. 如何將手勢添加到UITableViewController?
- 30. 如何將自定義背景添加到UISearchDisplayController的表視圖?
看看這個問題,答案標記爲正確的。 http://stackoverflow.com/a/1637871/1354251列出的步驟說創建一個UIViewController,然後以編程方式在背景圖像上創建您的TableView。 – Kyle 2013-03-15 19:18:53
@Kyle這是一個相當古老的問題,我認爲現在最好使用setBackgroundView方法 – guenis 2013-03-15 19:36:11