How to Create ActionSheet in IOS

How to Create ActionSheet in IOS

Action Sheets
An action sheet is a specific style of alert that appears in response to a control or action, and presents a set of two or more choices related to the current context. Use an action sheet to let people initiate tasks, or to request confirmation before performing a potentially destructive operation. On smaller screens, an action sheet slides up from the bottom of the screen. On larger screens, an action sheet appears all at once as a popover.

Provide a Cancel button if it adds clarity. A Cancel button instills confidence when the user is abandoning a task. Cancel buttons should always be included in action sheets at the bottom of the screen.

Make destructive choices prominent. Use red for buttons that perform destructive or dangerous actions, and display these buttons at the top of an action sheet.

Avoid enabling scrolling in an action sheet. If an action sheet has too many options, people must scroll to see all of the choices. Scrolling requires extra time to make a choice and is hard to do without inadvertently tapping a button.

Setting Properties
delegate
The receiver’s delegate or nil if it doesn’t have a delegate.

title
The string that appears in the receiver’s title bar.

visible
A Boolean value that indicates whether the receiver is displayed.

actionSheetStyle
The receiver’s presentation style.

Configuring Buttons
– addButtonWithTitle:
Adds a custom button to the action sheet.

numberOfButtons
The number of buttons on the action sheet.

– buttonTitleAtIndex:
Returns the title of the button at the specified index.

cancelButtonIndex
The index number of the cancel button.

destructiveButtonIndex
The index number of the destructive button.

firstOtherButtonIndex
The index of the first custom button.

Presenting the Action Sheet
– showFromTabBar:
Displays an action sheet that originates from the specified tab bar.

– showFromToolbar:
Displays an action sheet that originates from the specified toolbar.

– showInView:
Displays an action sheet that originates from the specified view.

– showFromBarButtonItem:animated:
Displays an action sheet that originates from the specified bar button item.

– showFromRect:inView:animated:
Displays an action sheet that originates from the specified view.

Dismissing the Action Sheet
– dismissWithClickedButtonIndex:animated:
Dismisses the action sheet immediately using an optional animation.

Constants
UIActionSheetStyle
Specifies the style of an action sheet.

 

To add an image in an action sheet you need to do something like this…

Swift

Objective C