What is PngCrush in iOS?

拟墨画扇 提交于 2019-11-27 22:34:45

Xcode does the conversion during build. The final app will have modified pngs, you don't have to do anything manually.

The PNG crushing is done using the pngcrush tool which you can access manually with this command:

xcrun -sdk iphoneos pngcrush -iphone ...

Xcode will do this automatically for any files added to your target with the "PNG" file type:

If you include resources using a directory reference, the PNG crushing will not be performed by Xcode and you will have to do this manually.

You can crush all the PNGs in a directory manually using this little bash snippet:

find /path/to/directory -name "*.png" | while read filename; do
    xcrun -sdk iphoneos pngcrush -iphone "$filename" "${filename}_crushed"
    mv "${filename}_crushed" "${filename}"
done

By default, XCode performs automatically the crunching.

You can control this behavior from your project's build settings:

Search for the setting "Compress PNG Files" and set the value you want.

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