Reputation: 433
I have a swift playground in Xcode 7.3.1 and I am trying to load in this image into my program using let mouth = UIImage(named: "happy-mouth")
. When the program runs the swift compiler returns the image like this...
Why does the swift playground change the colour of the image to a maroon colour instead of a peach colour?
Things I have tried
Checking that the name of the image is "happy-mouth.png"
Checking that the image is under my resources folder in swift
Restarting Xcode
Googling my issue and searching for it on StackOverflow
Upvotes: 0
Views: 209
Reputation: 2264
This is a common issue with transparent images. As they are usually shown in a UIImageView
which inherits the background color from its parent view (superview) which is usually white, you don't get to notice that.
Instead of modifying the image, put it in a UIImageView
and set the background color (of the UIImageView
) to white.
Upvotes: 1
Reputation: 433
The issue is most likely that the image you have is partly transparent, because of that it mixes with the dark colour behind it changing the way it appears compared to how it appears on a white background. To fix this go back into your image editor (e.g. sketch, photoshop, illustrator) and make the colour opaque.
Upvotes: 0