Why do .png backgrounds appear black on iPhone device but not simulator? - iphone

I started with a .tiff file and used GraphicConverter to change it to a .png and set a transparency color. Worked fine in the simulator but when I pushed to the device the transparency color became black. Tested with a .png I downloaded from the net and that worked fine, so it seems to only happen with some files. Thus I suspect it has something to do with the way GraphicConverter writes the .pngs, but I don't know enough about file formats to debug it. Any ideas/suggestions? Ideally I'd like to programatically treat all .pngs because my app allowed dynamic loading of arbitrary files, so I can't verify the transparency beforehand.

PNGs, like most other image formats that support transparency, seem to have multiple ways to handle the alpha channel. Apple recommends the PNG-24 format; perhaps GraphicsConverter gave something else?
You can use Preview to convert your image files. The iPhone should like it better. Just open your file and Save As.

Related

Set image for tab bar IOS

I'm experiencing issue when trying to set png image for tab bar item icon for my iOS application. If I'm creating png image (with transparent background) and setting it, everything works as expected, but when I'm using another png file (created by another person, or downloaded from web) it not works. Actually in my case I'm making png file from .pdf file and it's absolutely not clear for me why this not works. For more information please see screen captures below (top image represents not working one).
Thanks in advance.
Those specific icons/buttons work funky in terms of PNG and transparency for those images. You have to have look at the png's you download in image preview, make sure transparency exists for the white space. If there is whitespace it'll come through and show in your iOS app. Any other nonwhitepsace transparency will show up dark. It threw me off the first time I encountered this, A lot of graphics and PNG's you download from the internet doesn't have transparency built in or they have it very subtle. THose will show up as a blob for your ViewController Tabs.
Here is a good resource and guideline I found: http://steveweller.com/articles/toolbar-icons/

iPhone 5 Web Browser - transparent .png with black matte

I often use 24-bit transparent .png files in web design. I recently checked an iPhone 5, mostly to look at the viewport, and noticed my .png files all have a black matte?
Went back and checked an iPhone 4 and everything looks fine there. Not sure what to say. I've been saving files the same way since 2007! Either a save-for-web from Photoshop or a direct save-as.
Any ideas? Is mobile Safari the new IE 6?
I looked into this a little more, including testing more than one iPhone5.
It's a colour profile issue saving out of Photoshop. I opened the files and assigned a colour profile (I assigned sRGB to one and colormatch to the other) and they work fine with either.
Normally I use sRGB for all my images, so it's strange, but definitely a local issue to my files, as saved from Photoshop. It doesn't totally make sense to me that the colour profile wasn't there in the first place, but at least I understand this now.
Hope fully it helps someone.

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

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
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.
Load the file, select all, and copy to clipboard
Create a new file in photoshop that is the same dimension, RGB and 8bit depth with 72pixels/inch resolution with a white background.
Paste the image you copied in step 1 into this image
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.
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.
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.

Can i use a jpeg image for launching Screen

i was currently in to an app development and i have added a launcher screen in JPEG format which is displayed both in simulator and device .. but does it create any problem with apple approval guidelines ?
Update for iOS 8+: you can now use XIB-based launch assets, which is by far the best approach to reduce file size and re-use the same assets for multiple screens sizes. Also, since XIBs support JPG assets, you can always embed JPGs onto XIB files now too!
The Apple documentation pre iOS 8 (now removed), explicitly stated that only PNG is allowed for the launch image:
App Launch (Default) Images
Every app must provide at least one launch image. This image is
typically in a file named Default.png that displays your app’s initial
screen in a portrait orientation. However, you can also provide other
launch images to be used under different launch conditions. All launch
images must be PNG files and must reside in the top level of your
app’s bundle directory. (Avoid using interlaced PNGs.)
I can't speak to how accurate this document is, but it seems they are pretty specific on this point.
My advice: use 8-bit PNG's, and if your files are getting to big, simply don't include the #2x versions for the retina iPad. The 1x version upscales reasonably well on the retina iPad, and better than bloating your app by 5MB+
Yes ofcourse you can use JPEG image in Launch screen or anywhere in project.NO it absolutely does not create any problems in approval process of Apple.So go ahead and code!
Use a png if you can; not only is png artwork better visually, but iOS is optimised for png files.
While it is true Apple won't reject your app for using a jpeg, your users might.
NO you should not use jpgs
Here are apple recomendations
Note: For all images and icons, the PNG format is recommended.
The standard bit depth for icons and images is 24 bits (8 bits each for red, green, and blue), plus an 8-bit alpha channel.
You do not need to constrain your palette to web-safe colors. Although you can use alpha transparency in the icons you create for navigation bars, toolbars, and tab bars, do not use it in application icons.
You can only use PNG files for the launch images. Here is the proof.
Yes , you can choose any one from JPEG/PNG.There is no guidelines from apple to choose type of image.
For more information you can follow apple launch image guidelines.
but I assume that PNGs are more preferable because Apple seems to use PNGs virtually everywhere in iPhone OS.

iPhone screenshot different colour when displayed

I've taken a screenshot of my iPhone app running and I'd like to use that image as a png to be drawn by the app instead of generated graphics.
When I take the screenshot, it looks fine. However, when that is saved as a PNG file, added to the Xcode project and then displayed back on the screen of the phone (or simulator) the colours are different.
Can anyone explain to me why it's changing? (I'm guessing there's a colour space conversion happening).
How can I stop this from changing?
You might be saving the png image with some incorrect settings which is either reducing the quality or number of colors used. Try the PNG-24 with transparency to see if that helps at all.