iOS 5.1 with Xcode 4.3.1: [UIColor colorWithPatternImage:] strange behavior only on device

老子叫甜甜 提交于 2019-11-27 04:15:37

问题


When I compile my app in Xcode 4.3.1 with iOS 5.1, I notice there is a strange behavior with background textures only on actual device. There is a 1px gap in between texture tiles shown in screenshot below.

My texture are 150x150 and 300x300 at 2x.

So far I've tested the same build on:

  • Simulator iPhone/iPad both 5.0/5.1: No bug
  • iPhone/iPad running 5.0.1: No bug
  • iPhone/iPad running 5.1: Buggy


回答1:


I've been getting the same problem since 5.1 aswell. I solved it by doing the following to the image in photoshop. You can probably do the same in another tool.

  1. Load the file, select all, and copy to clipboard

  2. Create a new file in photoshop that is the same dimension, RGB and 8bit depth with 72pixels/inch resolution with a white background.

  3. Paste the image you copied in step 1 into this image

  4. Save the file and use this one.

After doing this the file displayed correctly on the device and I didn't have to resort to creating images the size of the display.




回答2:


My workaround: Set "Compress PNG Files" to "No" in Build Settings. In my case the size of the app bundle was even smaller than with compression turned on. I did image optimization myself.




回答3:


just in case anyone else is having this problem and uses pngoptimizer, try a new png without optimizing it.

I had the same problem and spent the last 4 hours trying to solve it. In the end i realized it was png file from the pngoptimizer tool that somehow always worked before iOS 5.1 but with the update the same png file produces this thin line at the bottom. the strange thing is that this does only happen on the device and not in simulator and that deceives you a lot because you think it cant be the graphic. in fact it is.



来源:https://stackoverflow.com/questions/9630870/ios-5-1-with-xcode-4-3-1-uicolor-colorwithpatternimage-strange-behavior-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!