How to create custom UIAlertView

前端 未结 6 1859
伪装坚强ぢ
伪装坚强ぢ 2021-01-14 10:19

We\'re creating an immersive app that needs to have something that acts rather similar to a UIAlertView, but we don\'t want it to look like a system dialog, we

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-14 10:34

    You need to create a new Window where you can put your alert view:

    UIWindow *alertWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // you must release the window somewhere, when you do not need it anymore
    alertWindow.windowLevel = UIWindowLevelAlert; // puts it above the status bar
    alertWindow.backgroundColor = [UIColor clearColor];
    UIViewController *alertVC = [[[YourAlertViewController alloc] init] autorelease];
    [alertWindow setRootViewController:alertVC];
    [alertWindow setHidden:NO];
    

提交回复
热议问题