YRDropdownView – A Polite UIAlertView Alternative for iOS
YRDropdownView is an iOS library for displaying stylish alerts, warnings, and errors
UIKit’s Shortcomings
From day one, iOS developers have been struggling to alert users about simple warnings and errors that may not interrupt the flow of the app. Popping up UIAlertViews requires the user to click a button to move along, which wasn’t quite necessary for warnings that merely limit useability. Adding a UILabel somewhere on the screen isn’t consistent and doesn’t always look great.
Maybe you just have some more information you want to inform your user about. Simply adding it to the screen is sufficient, but what if your information is added off screen? How does your user know it has appeared? TweetBot found a great solution to that. By overlaying a simple panel, with an icon, title, and message, the flow of the app is uninterrupted, yet informs the user in a concise manner.

Imitation Is The Greatest Form Of Flattery

YRDropdownView is a simple and versitile class that will increase the visibility of information relating to your app in a stylish way. YRDropdownView draws inspiration from such libraries like MKInfoPanel, MBProgressHUD, and DSActivityView and fills the gaps where these classes left off.
Usage
herever you want to use YRDropdownView, import the header file as follows:
#import "YRDropdownView.h"
Basic
You can create your dropdown by calling the singleton method:
[YRDropdownView showDropdownInView:self.view
title:@"Warning"
detail:@"Danger Will Robinson. You cannot do that."];
By default, calling the above method will only dismiss when clicked on. To dismiss manually in your code, call:
[YRDropdownView hideDropdownInView:self.view];
Customizing
There are many different ways to customize the alert by calling different singleton methods:
+ (YRDropdownView *)showDropdownInView:(UIView *)view
title:(NSString *)title;
+ (YRDropdownView *)showDropdownInView:(UIView *)view
title:(NSString *)title
detail:(NSString *)detail;
+ (YRDropdownView *)showDropdownInView:(UIView *)view
title:(NSString *)title
detail:(NSString *)detail
animated:(BOOL)animated;
+ (YRDropdownView *)showDropdownInView:(UIView *)view
title:(NSString *)title
detail:(NSString *)detail
image:(UIImage *)image
animated:(BOOL)animated;
+ (YRDropdownView *)showDropdownInView:(UIView *)view
title:(NSString *)title
detail:(NSString *)detail
image:(UIImage *)image
animated:(BOOL)animated
hideAfter:(float)delay;
+ (BOOL)hideDropdownInView:(UIView *)view;
+ (BOOL)hideDropdownInView:(UIView *)view animated:(BOOL)animated;
+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
title:(NSString *)title;
+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
title:(NSString *)title
detail:(NSString *)detail;
+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
title:(NSString *)title
detail:(NSString *)detail
animated:(BOOL)animated;
+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
title:(NSString *)title
detail:(NSString *)detail
image:(UIImage *)image
animated:(BOOL)animated;
+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
title:(NSString *)title
detail:(NSString *)detail
image:(UIImage *)image
animated:(BOOL)animated
hideAfter:(float)delay;
+ (BOOL)hideDropdownInWindow:(UIWindow *)window;
+ (BOOL)hideDropdownInWindow:(UIWindow *)window animated:(BOOL)animated;
Notes
Label and Background Customization
Currently, the title and detail labels, as well as the yellow background, are static for all dropdowns. Customizing these features are a TODO for this project.
Automatic Reference Counting (ARC) support
ARC support has been neglected in part for now. Your contributions are more than welcome, however. If you want to use YRDropdownView in an ARC project, just add the add the compiler flag:
-fno-objc-arc
to all YRDropdownView files in your project.
Project on GitHub
For the cutting edge releases and outstanding issues, we’ve set up a GitHub repository to keep everything in order. Feel free to post any code related issues or contributions there in addition to in the comments below. We’ll also be doing minor releases there from time to time without making full blog posts. Enjoy!



