Why do my UIButtons look transparent in iOS4 when they looked fine in iOS3.1.x?
I have an app under development that worked fine under iOS 3.1.x. I was at a good break point开发者_如何学Go, so I decided to upgrade my dev environment to XCode 3.2.4 + iOS4.1.
My app has a number of UIButtons that I made colored using the "stretch a colored image as background" technique described elsewhere on StackOverflow:
UIImage *myImage = [UIImage imageNamed:GREEN_BTN_IMAGE];
UIImage *stretchableMyImage = [myImage stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[myBtn setBackgroundImage:stretchableMyImage forState:UIControlStateNormal];
This worked great until I recompiled using my new environment. Now, the button is basically transparent, with the text showing. I can't seem to get the coloring to show up, no matter how much fiddling I do with the IB version of the button or in code.
Any ideas on what might be wrong? Also, is there a good resource somewhere for other 3.1 to 4.x migration gotchas? I've been looking through the WWDC videos, but have not stumbled upon anything yet.
Thanks.
I think, you have to update your image resources to high resolution. Since iPhone 4 has exactly the double resolution as iPhone 3GS. Please look into updated iOS App Programming Guide, "Loading Images into Your Application" section.
精彩评论