[英]iOS Background image doesn't work on device
這是我的概率:
我將此添加到我的代碼:
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bgWhiteLight"]]];
而且它在iOS模擬器中可以正常工作,但是當我在真實設備上對其進行測試時,它根本無法工作。 請注意,我重新定義了
self.navigationItem.titleView
但是模擬器中根本沒有鉛,只有在真實設備上才有鉛!
謝謝
有時僅指定文件名是不夠的,您可以執行以下操作
NSString *path = [[NSBundle mainBundle] pathForResource:@"bgWhiteLight" ofType:@"jpg"];
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[[UIImage alloc] initWithContentsOfFile:path]];
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bgWhiteLight.png"]]];
嘗試這個。 給出圖像的全名
在設備上,名稱區分大小寫。 確保其名稱正確。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.