Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Making by background image dim when the keyboard is present in IOS 7

Hey guys and girls,

I am building a simple-ish login screen.

When the keyboard raises the text fields move up out the way so they can be seen when editing. but how do I make the imageView object darker when that happens so it does not interfere?

1 Answer

Dimitris Sotiris Tsolis
Dimitris Sotiris Tsolis
28,141 Points

First, you have to set the tintColor property of your imageView to a color

imageView.tintColor = [UIColor darkGrayColor];

then, when the keyboard is visible, change the rendering mode of the image...

UIImage *theImage = [imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
imageView.image = theImage;

...and when the keyboard disappears, change it back to the original rendering mode

UIImage *theImage = [imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
imageView.image = theImage;

Awesome thank you, with a little jiggling and that advice, works perfect!