Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Growl/toast style notifications library for iOS

Can anyone recommend a library for implementing growl or toast-style notifications on iOS? For example, after a user saves a profile, I want to have a notification fade in, linger for 3 seconds, report "profile saved", and fade out. Right now I have a UIAlertView that interrupts the user's workflow with a single "OK" button, and I feel like that is overkill.

The Android Toast class is an example of what I am looking for on iOS.

Thanks!

like image 951
esilver Avatar asked May 17 '11 04:05

esilver


4 Answers

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"];
like image 95
user2393462435 Avatar answered Nov 05 '22 08:11

user2393462435


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.

like image 32
nickeyzzz Avatar answered Nov 05 '22 09:11

nickeyzzz


Albeit a little late, here's my take on it:

https://github.com/pcperini/PCToastMessage

like image 5
Patrick Perini Avatar answered Nov 05 '22 08:11

Patrick Perini


You could try my open source library TSMessages: https://github.com/toursprung/TSMessages

It's really easy to use and looks beautiful on iOS 5/6 and on iOS 7 as well.

like image 5
KrauseFx Avatar answered Nov 05 '22 08:11

KrauseFx