开发者

Annoying white border when rotating a view in iPad

When rotating a View from UIInterfaceOrientationPortrait to UIInterfaceOrientationPortraitUpsideDown on the iPad simulator, there is a white border along one side of the view (see diagram, lower left of the image). The white border shows only on one side, but not the opposite side.开发者_如何学C How can I prevent (hide) it? Thanks!


This is a guess:

It's possible that one of your views has a backgroundColor set to white, and it is completely covered by another view. During a rotation, perhaps floating point errors cause one border to show slightly through that edge.

To investigate this case, you can use the undocumented method [UIView recursiveDescription] to get a quick look at your view hierarchy (no need to submit code with that method, it's just for debugging). Once you know which views are near the bottom, you can print out their backgroundColors, or just set them all to [UIColor clearColor].

Also, I'm guessing you already know this one, but it can be useful to set window.backgroundColor = [UIColor clearColor] at the start of your code!


I had the same issue. I saw that in Interface builder autosizing for the view could not be enabled. I deleted the .xib and re-created it making sure product was set to "ipad" when creating the file (add new file in xcode).


You can also set the background color to nil. From the UIView documentation for backgroundColor:

The default value is nil, which results in a transparent background color.

UIWindow inherits from UIView, so this works as well. Probably a good idea to use nil, in case [UIColor clearColor] isn't always the best way to do it.

The funny thing is, I have a project with no nibs, so I create the UIWindow in code, but the background color was white before I set it to nil. is the default background color of a programmatically created UIWindow white?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜