Growl/toast style notifications library for iOS Growl/toast style notifications library for iOS ios ios

Growl/toast style notifications library for iOS


I created a solution that I think you'll find useful:https://github.com/scalessec/toast

It's written as a obj-c category, essentially adding makeToast methods to any instance of UIView. eg:

[self.view makeToast:@"Profile saved"            duration:2.0            position:@"bottom"];


I solved it this way:

  1. Create common label on your view. Make it all screen wide, give it the size you will need and center text in it.
  2. Set it's position "on top" - this label must be below all of your controls in the list of controls.
  3. Add it to interface, properties, synthesize (let's call it "toastLabel" there).
  4. Associate in your XIB file with "toastLabel"
  5. Add following line to your viewWillAppear to hide label for beginning:

    [toastLabel setHidden:TRUE];
  6. Add the following code on Button click (or some other event):

    toastLabel.text = @"Our toast text";[toastLabel setHidden:TRUE];[toastLabel setAlpha:1.0];CGPoint location;location.x = 160; location.y = 220; toastLabel.center = location;location.x = 160; location.y = 320; [toastLabel setHidden:FALSE];[UIView animateWithDuration:0.9 animations:^{    toastLabel.alpha = 0.0;    toastLabel.center = location;}];

This label will "fall down" and disappear.