SDCAlertView doesn't just look like a system alert in terms of user interface elements, it is the result of completely reverse-engineering UIAlertView. View hierarchy, labels, table views, animations, user interaction; everything has been looked at and incorporated as much as possible.
You can think of SDCAlertView as UIAlertView on steroids. It has added functionality such as a contentView property and block syntax, while still keeping the UIAlertView look.
Check for yourself:
- Entire
UIAlertViewpublic API, includingUIAlertViewDelegate - The dimensions and positioning of all views in all alert configurations
- Showing and dismissing animations
- Faded background, blurring, and disabling of underlying UI elements
- User interaction with alert, including parallax effect
- Font sizes and colors for labels, text fields, and buttons
-
Special interaction with the system. The system does not consider instances of
SDCAlertViewactual alerts, which means that, for example, thealertViewCancel:method fromSDCAlertViewDelegatewill never be called. -
Text field placeholders in different languages. "Login" and "Password" are entered as localized strings, but they aren't actually translated.
-
Some behavior is purposely not ported from
UIAlertView. These cases are discussed in SDCAlertView.h.
The easiest way to install is, of course, by using CocoaPods. The name of the pod is SDCAlertView.
If you're not using CocoaPods, you need at least:
- SDCAlertView.{h,m}
- SDCAlertView_Private.h
- SDCAlertViewCoordinator.{h,m}
- SDCAlertViewController.{h,m}
- SDCAlertViewContentView.{h,m}
- SDCAlertViewBackgroundView.{h,m}
The project also depends on RBBAnimation and SDCAutoLayout. These dependencies are automatically handled for you if you use CocoaPods.
SDCAlertView is for use in iOS 7 only. It will not work properly on iOS 6.1 or below. Using SDCAlertView is simple: just import SDCAlertView.h and use it as you would UIAlertView. In addition to that, SDCAlertView has some added functionality, including:
-
contentView. ThecontentViewproperty can be used to add custom views to the alert. See SDCAlertView.h for details on how to use this. For sample uses, see SDCViewController. -
Block syntax. Some delegate methods have block alternatives as settable properties that you can use for simple implementations. There's also a convenient
showWithDismissHandler:method to make handling a dismissal even easier. -
Additional delegate methods:
alertView:shouldDismissWithButtonIndex:andalertView:shouldDeselectButtonWithIndex: -
Theme support (v1.1+). You can style (with limitations) your alert to your liking.
If you have questions, please use Stack Overflow, or use Twitter to contact me directly.
Some credits are in order:
- Robert Böhnke (@robb): RBBAnimation
- Lee McDermott (@lmcd) for reverse-engineering the showing and dismissing animations.
- César Castillo (@JagCesar) for the great idea of using a
UIToolbarfor easy live blurring (used in earlier versions of SDCAlertView).
And everyone else who contributed by reporting issues, creating pull requests, or in some other way!
