SDCAlertView is intended as a pixel-for-pixel UIAlertView duplicate in iOS 7, with added functionality that a particular company at a particular developer's conference promised, but never delivered. Most importantly, SDCAlertView adds support for custom content using the contentView property.
SDCAlertView doesn't just look like a system alert in terms of user interface elements, it is the result of completely reverse-engineering UIAlertView. The view hierarchy, labels, table views, animations, everything has been looked at and incorporated as much as possible.
Check for yourself:
- Entire
UIAlertViewpublic API, includingUIAlertViewDelegate - The dimensions and positioning of all views in all alert configurations
- Font sizes for labels, text fields, and buttons
- User interaction with alert, including parallax effect
- Showing and dismissing animations
- Faded background and disabling of underlying UI elements
-
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.
The only thing that is currently lacking in SDCAlertView is properly queueing and displaying multiple alert views (see issue #3). All other features are expected to work exactly like UIAlertView.
The usage is almost exactly the same as it is for UIAlertView. Most documentation that applies to some UIAlertView API, also applies to the same SDCAlertView API. There are a few exceptions, please see SDCAlertView.h for details.
To use the contentView property, you have to apply auto-layout constraints to it and its subviews. The contentView property will be the same width as the alert, but the height is dependent on its content, so you have to set that too. See SDCViewController for a few examples of how to use contentView. See SDCAutoLayout for an NSLayoutConstraint category that makes creating constraints a little easier.
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}
- SDCAlertViewViewController.{h,m}
- SDCAlertViewContentView.{h,m}
- SDCAlertViewBackgroundView.{h,m}
- SDCAlertViewBackground.png (for older generation iPads)
- [email protected]
The project also depends on RBBAnimation and SDCAutoLayout. These dependencies are handled for you if you use Cocoapods.
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
