# UIView(TCGBToast) Category Reference

Declared in | UIView+Toast.h UIView+Toast.m

## Overview

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.

The `makeToast:` methods create a new view and then display it as toast.

The `showToast:` methods display any view as toast.

### `– makeToast:`

Creates and presents a new toast view with a message and displays it with the default duration and position. Styled using the shared style.

`- (void)makeToast:(NSString *)message`

#### Parameters

`message` | The message to be displayed

#### Declared In

`UIView+Toast.h`

### `– makeToast:duration:position:`

Creates and presents a new toast view with a message. Duration and position can be set explicitly. Styled using the shared style.

`- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position`

#### Parameters

`message` | The message to be displayed
`duration` | The toast duration
`position` | The toast’s center point. Can be one of the predefined TCGBToastPosition constants or a `CGPoint` wrapped in an `NSValue` object.

#### Declared In

`UIView+Toast.h`

### `– makeToast:duration:position:style:`

Creates and presents a new toast view with a message. Duration, position, and style can be set explicitly.

`- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position style:(TCGBToastStyle *)style`

#### Parameters

`message` | The message to be displayed
`duration` | The toast duration
`position` | The toast’s center point. Can be one of the predefined TCGBToastPosition constants or a `CGPoint` wrapped in an `NSValue` object.
`style` | The style. The shared style will be used when nil

#### Declared In

`UIView+Toast.h`

### `– makeToast:duration:position:title:image:style:completion:`

Creates and presents a new toast view with a message, title, and image. Duration, position, and style can be set explicitly. The completion block executes when the toast view completes. `didTap` will be `YES` if the toast view was dismissed from a tap.

`- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position title:(NSString *)title image:(UIImage *)image style:(TCGBToastStyle *)style completion:(void ( ^ ) ( BOOL didTap ))completion`

#### Parameters

`message` | The message to be displayed
`duration` | The toast duration
`position` | The toast’s center point. Can be one of the predefined TCGBToastPosition constants or a `CGPoint` wrapped in an `NSValue` object.
`title` | The title
`image` | The image
`style` | The style. The shared style will be used when nil
`completion` | The completion block, executed after the toast view disappears. didTap will be `YES` if the toast view was dismissed from a tap.

#### Declared In

`UIView+Toast.h`

### `– toastViewForMessage:title:image:style:`

Creates a new toast view with any combination of message, title, and image. The look and feel is configured via the style. Unlike the `makeToast:` methods, this method does not present the toast view automatically. One of the showToast: methods must be used to present the resulting view.

`- (UIView *)toastViewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image style:(TCGBToastStyle *)style`

#### Parameters

`message` | The message to be displayed
`title` | The title
`image` | The image
`style` | The style. The shared style will be used when nil

#### Return Value

The newly created toast view

#### Discussion

Warning: if message, title, and image are all nil, this method will return nil.

#### Declared In

`UIView+Toast.h`

### `– hideToasts`

Dismisses all active toast views. Any toast that is currently being displayed on the screen is considered active.

`- (void)hideToasts`

#### Discussion

Warning: this does not clear toast views that are currently waiting in the queue. The next queued toast will appear immediately after `hideToasts` completes the dismissal animation.

#### Declared In

`UIView+Toast.h`

### `– hideToast:`

Dismisses an active toast view.

`- (void)hideToast:(UIView *)toast`

#### Parameters

`toast` | The active toast view to dismiss. Any toast that is currently being displayed on the screen is considered active.

#### Discussion

Warning: this does not clear a toast view that is currently waiting in the queue.

#### Declared In

`UIView+Toast.h`

### `– makeToastActivity:`

Creates and displays a new toast activity indicator view at a specified position.

`- (void)makeToastActivity:(id)position`

#### Parameters

`position` | The toast’s center point. Can be one of the predefined TCGBToastPosition constants or a `CGPoint` wrapped in an `NSValue` object.

#### Discussion

Warning: Only one toast activity indicator view can be presented per superview. Subsequent calls to `makeToastActivity:` will be ignored until hideToastActivity is called.

Warning: `makeToastActivity:` works independently of the showToast: methods. Toast activity views can be presented and dismissed while toast views are being displayed. `makeToastActivity:` has no effect on the queueing behavior of the showToast: methods.

#### Declared In

`UIView+Toast.h`

### `– hideToastActivity`

Dismisses the active toast activity indicator view.

`- (void)hideToastActivity`

#### Declared In

`UIView+Toast.h`

### `– showToast:`

Displays any view as toast using the default duration and position.

`- (void)showToast:(UIView *)toast`

#### Parameters

`toast` | The view to be displayed as toast

#### Declared In

`UIView+Toast.h`

### `– showToast:duration:position:completion:`

Displays any view as toast at a provided position and duration. The completion block executes when the toast view completes. `didTap` will be `YES` if the toast view was dismissed from a tap.

`- (void)showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)position completion:(void ( ^ ) ( BOOL didTap ))completion`

#### Parameters

`toast` | The view to be displayed as toast
`duration` | The notification duration
`position` | The toast’s center point. Can be one of the predefined TCGBToastPosition constants or a `CGPoint` wrapped in an `NSValue` object.
`completion` | The completion block, executed after the toast view disappears. didTap will be `YES` if the toast view was dismissed from a tap.

#### Declared In

`UIView+Toast.h`