Skip to content

An easy drop in control that allows you to display a discrete alert in any view.

License

Notifications You must be signed in to change notification settings

kgn/KGDiscreetAlertView

Repository files navigation

KGDiscreteAlertView is an easy drop in control that allows you to display a discrete alert in any view.

You supply your own text and KGDiscreteAlertView does the rest to properly fit the text in the discrete alert and animate it down from the top of the specified view:

[KGDiscreteAlertView showDiscreteAlertWithText:@"KGDiscreteAlertView, add discrete alerts to any view!" inView:self.view];

There are a couple other options but it's purposely designed to be simple and easy to use:

#pragma mark - Convenience Class Methods

// Show a discrete alert with the given text in a view,
// the alert will be automatically dismissed after 3 seconds
+ (id)showDiscreteAlertWithText:(NSString *)text inView:(UIView *)view;

// Show a discrete alert with the given text in a view,
// the alert will be automatically dismissed after the specified delay.
// If the delay is 0 the alert will be 'sticky' and will not be dismissed until `hide` is called.
+ (id)showDiscreteAlertWithText:(NSString *)text inView:(UIView *)view delay:(NSTimeInterval)delay;

// Show a discrete alert with the given text in a view, and a max width for the alert.
// The alert will be automatically dismissed after the specified delay,
// if the delay is 0 the alert will be 'sticky' and will not be dismissed until `hide` is called.
+ (id)showDiscreteAlertWithText:(NSString *)text inView:(UIView *)view maxWidth:(CGFloat)maxWidth delay:(NSTimeInterval)delay;

#pragma mark - Instance Methods

// Show a discrete alert with the given text in a view,
// the alert will be automatically dismissed after 3 seconds
- (void)showWithText:(NSString *)text inView:(UIView *)view;

// Show a discrete alert with the given text in a view,
// the alert will be automatically dismissed after the specified delay.
// If the delay is 0 the alert will be 'sticky' and will not be dismissed until `hide` is called.
- (void)showWithText:(NSString *)text inView:(UIView *)view delay:(NSTimeInterval)delay;

// Show a discrete alert with the given text in a view, and a max width for the alert.
// The alert will be automatically dismissed after the specified delay,
// if the delay is 0 the alert will be 'sticky' and will not be dismissed until `hide` is called.
- (void)showWithText:(NSString *)text inView:(UIView *)view maxWidth:(CGFloat)maxWidth delay:(NSTimeInterval)delay;

// Dismiss the discrete alert.
- (void)hide;

Check out the ExampleApp to see it in action!

About

An easy drop in control that allows you to display a discrete alert in any view.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published