mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-20 08:27:32 +08:00
This PR adds the Action Sheet component for the iOS platform. In a later PR theming will be added and then an App Bar to support full screen.
1.6 KiB
1.6 KiB
Typical use
Create an instance of MDCActionSheetController and add actions to it. You can now
present the action sheet controller.
Swift
let actionSheet = MDCActionSheetController(title: "Action Sheet",
message: "Secondary line text")
let actionOne = MDCActionSheetAction(title: "Home",
image: UIImage(named: "Home"),
handler: { print("Home action" })
let actionTwo = MDCActionSheetAction(title: "Email",
image: UIImage(named: "Email"),
handler: { print("Email action" })
actionSheet.addAction(actionOne)
actionSheet.addAction(actionTwo)
present(actionSheet, animated: true, completion: nil)
Objective-C
MDCActionSheetController *actionSheet =
[MDCActionSheetController actionSheetControllerWithTitle:@"Action sheet"
message:@"Secondary line text"];
MDCActionSheetAction *homeAction =
[MDCActionSheetAction actionWithTitle:@"Home"
image:[UIImage imageNamed:@"Home"]
handler:nil];
MDCActionSheetAction *favoriteAction =
[MDCActionSheetAction actionWithTitle:@"Favorite"
image:[UIImage imageNamed:@"Favorite"]
handler:nil];
[actionSheet addAction:homeAction];
[actionSheet addAction:favoriteAction];
[self presentViewController:actionSheet animated:YES completion:nil];