Skip to content

SDCAlertView is a UIAlertView clone with added functionality including a contentView property

License

Notifications You must be signed in to change notification settings

thomasSailing/SDCAlertView

 
 

Repository files navigation

SDCAlertView

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.

Are you sure it's the same?

Check for yourself:

Animated GIF showing alert

What has been successfully duplicated:

  • Entire UIAlertView public API, including UIAlertViewDelegate
  • 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

What won't or can't be duplicated:

  • Special interaction with the system. The system does not consider instances of SDCAlertView actual alerts, which means that, for example, the alertViewCancel: method from SDCAlertViewDelegate will 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.

Installation

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.

Usage

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. The contentView property 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: and alertView:shouldDeselectButtonWithIndex:

  • Theme support (v1.1+). You can style (with limitations) your alert to your liking.

Questions

If you have questions, please use Stack Overflow, or use Twitter to contact me directly.

Credits

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 UIToolbar for 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!

About

SDCAlertView is a UIAlertView clone with added functionality including a contentView property

Resources

License

Stars

Watchers

Forks

Packages

No packages published