开发者

Display UIView overlay?

I have a relatively complicated app. I want to display a view ov开发者_开发知识库er the entire app, regardless of orientation. How can I do this?

Thanks you!


You could create a second window in -applicationDidFinishLaunching.

UIWindow *secondWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
secondWindow.windowLevel = (UIWindowLevelAlert + 1000.0);
secondWindow.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.5];
secondWindow.userInteractionEnabled = NO;
[secondWindow makeKeyAndVisible];

This works fine for me. I do, however, not work with IB. Dunno if it works well with Interface Builder.


Allocate a new view, set its properties (like alpha, backgroundColor, whatever you want), and frame (set it the same as the window).
Once you got your view, add it as a subview of the window, it will take the entire screen.
You could also set userInteractionEnabled to NO.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜