環(huán)境:Xcode 7 + iOS9 模擬器
問題:使用IB方式構(gòu)建UI設(shè)置圖片的時候,發(fā)覺模擬器中UIImageView中的圖片顏色比原始圖片顏色深。而我希望得到的是原始圖片的效果。
新建了一個Demo,只放了一個ImageView。
圖片顏色有差異,模擬器中的圖片顏色(左圖)明顯比 IB中原始圖片(右圖)的顏色深。
做過以下嘗試,均未達(dá)到目的:
在xcassets文件中設(shè)置了圖片的渲染模式,設(shè)置圖片渲染模式為Original Image(如下圖),結(jié)果沒有效果。
我嘗試使用純代碼的方式設(shè)置UIImage結(jié)果還是沒有效果。
UIImage *image = [UIImage imageNamed:@"personal"];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
3.然后使用方法 imageWithContentsOfFile: 獲取,結(jié)果還是一樣沒有效果。
NSString *path = [[NSBundle mainBundle] pathForResource:@"personal.png" ofType:nil];
UIImage *imageOfFile = [UIImage imageWithContentsOfFile:path];
self.imageView.image = imageOfFile;
擁有18年軟件開發(fā)和IT教學(xué)經(jīng)驗(yàn)。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項(xiàng)目經(jīng)理、高級軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...
The following are pictures of the results of my test:
Comparing the pictures, the above is @2X generated by RTImageAssets, and the below is @2X generated by myself.
There is no color difference when displayed in IB, but there is color difference when displayed in the simulator.
Picture file list