8000 GitHub - haijiaoliuhao91/Toast: An Objective-C category that adds toast notifications to the UIView object class.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

haijiaoliuhao91/Toast

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
< 8000 svg aria-hidden="true" focusable="false" class="octicon octicon-file-directory-fill icon-directory" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom">
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Toast for iOS

Build Status CocoaPods Version Carthage Compatible

Toast is an Objective-C category that adds toast notifications to the UIView object class. It is intended to be simple, lightweight, and easy to use. Most toast notifications can be triggered with a single line of code.

Using Swift? A native swift port of this library is now available: Toast-Swift

Screenshots

Toast Screenshots

Basic Examples

// basic usage
[self.view makeToast:@"This is a piece of toast."];

// toast with a specific duration and position
[self.view makeToast:@"This is a piece of toast with a specific duration and position." 
            duration:3.0
            position:CSToastPositionTop];

// toast with all possible options
[self.view makeToast:@"This is a piece of toast with a title & image"
            duration:3.0
            position:[NSValue valueWithCGPoint:CGPointMake(110, 110)]
               title:@"Toast Title"
               image:[UIImage imageNamed:@"toast.png"]
               style:nil
          completion:^(BOOL didTap) {
              if (didTap) {
                  NSLog(@"completion from tap");
              } else {
                  NSLog(@"completion without tap");
              }
          }];
                
// display toast with an activity spinner
[self.view makeToastActivity:CSToastPositionCenter];

// display any view as toast
[self.view showToast:myView];

But wait, there's more!

// create a new style
CSToastStyle *style = [[CSToastStyle alloc] initWithDefaultStyle];

// this is just one of many style options
style.messageColor = [UIColor orangeColor];

// present the toast with the new style
[self.view makeToast:@"This is a piece of toast."
            duration:3.0
            position:CSToastPositionBottom
               style:style];

// or perhaps you want to use this style for all toasts going forward?
// just set the shared style and there's no need to provide the style again
[CSToastManager setSharedStyle:style];

// toggle "tap to dismiss" functionality
[CSToastManager setTapToDismissEnabled:YES];

// toggle queueing behavior
[CSToastManager setQueueEnabled:YES];

// immediately hides all toast views in self.view
[self.view hideAllToasts];

See the demo project for more examples.

Setup Instructions

Install with CocoaPods by adding the following to your Podfile:

pod 'Toast', '~> 4.0.0'