Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField background behaviour change from iOS 4 to iOS 5

In my app I have a UITextField which is on top of a background image. Under iOS 4 I had to set the backgroundColor property to 'clearColor' in order to make it look right. Under iOS 4 the textfield looks like this...

enter image description here

This is how I want it to look. Now, since upgrading to Xcode 4.3 (iOS 5) when I re-run the same project, the box looks like this...

enter image description here

Grrr. So under iOS 5 I changed the backgroundColor property to 'whiteColor' and it works fine. However now, under iOS 4.x the box looks like this...

enter image description here

Note the ugly white corners! So please, can anyone tell me what I should be doing here in order to get it to look normal under both iOS 4 and iOS 5 (i.e. To look like the first image!).

Many thanks, Simon

like image 443
Simon Avatar asked Nov 02 '11 08:11

Simon


3 Answers

I got the same problem a few days ago. To solve this, I just set the borderStyle and comment the backgroundColor line. Everything just work fine, both iOS4 and iOS5.

//  textField.backgroundColor = [UIColor clearColor]; // just leave it, dont't set
textField.borderStyle = UITextBorderStyleRoundedRect;
like image 173
Tranz Avatar answered Nov 07 '22 20:11

Tranz


This is what i did to resolve this issue, you can check the version of iOS running on the device and do the handling accordingly, like this

float version = [[[UIDevice currentDevice]systemVersion]floatValue];
if(version < 5.0)
{
//user clear color
}else
{
//use white color
}

Hope this helps you.

like image 30
Rachit Avatar answered Nov 07 '22 22:11

Rachit


Sometimes you might have to rebuild your project. Also, try and make this in a whole new project to see if it is actually a new change to Xcode, or if it is just that particular project to narrow things down. If you then isolate it to being something wrong with your particular project, try and "do it over" to see if it clicks then. But i see you solved it :=)

like image 1
Seerex Avatar answered Nov 07 '22 20:11

Seerex