How to create custom UIAlertView

前端 未结 6 1850
伪装坚强ぢ
伪装坚强ぢ 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:20

    What about working around the issue by hiding the status bar when the alert is displayed? That would make it more "alerty" anyway...

    0 讨论(0)
  • 2021-01-14 10:20

    For the opacity issue: have you considered embedding button graphics into the background image, and making the button controls themselves transparent, changing the background image every time a button is pushed down or released?

    0 讨论(0)
  • 2021-01-14 10:26

    Seems an old post but if you hit this page looking for an answer check this out

    http://joris.kluivers.nl/iphone-dev/?p=CustomAlert

    0 讨论(0)
  • 2021-01-14 10:33

    How do I make the UIView show up above the status bar (so that I can darken in, like a UIAlertView does)? Is this possible?

    I don't think Apple makes this available to a non-UIAlertView subclass of UIView.

    UIAlertView is a subclass of UIView. Have you tried subclassing UIAlertView and overriding -drawRect: with your own drawing code?

    0 讨论(0)
  • 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];
    
    0 讨论(0)
  • 2021-01-14 10:38

    If the default behavior of UIAlertView works for you, I'd suggest changing the default look of the dialog. You can for example use the example code from this discussion and provide your own image.

    0 讨论(0)
提交回复
热议问题