Sem*_*nko 3 user-interface ios
如何在iOS上创建像Instagram取消关注警报(两个按钮,图像和消息)的提醒?有没有现成的组件或我应该从头开发它?这是一个截图:
有一个实现(UIAlertController),但没有图像.
这是一个有效的例子:
UIAlertController* deleteAlert = [UIAlertController alertControllerWithTitle:@"Unfollow?"
message:
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* unfollowAction = [UIAlertAction actionWithTitle:@"Unfollow" style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action) {
//Code to unfollow
}];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
}];
[deleteAlert addAction:unfollowAction];
[deleteAlert addAction:cancelAction];
[self presentViewController:deleteAlert animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
在这篇文章中,您可以找到有关如何将图像添加到UIAlertController的更多信息:
在UIAlertController中将图像添加到UIAlertAction
小智 6
斯威夫特4版本
let deleteAlert = UIAlertController(title: "Unfollow", message: "", preferredStyle: UIAlertController.Style.actionSheet)
let unfollowAction = UIAlertAction(title: "Unfollow", style: .destructive) { (action: UIAlertAction) in
// Code to unfollow
}
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
deleteAlert.addAction(unfollowAction)
deleteAlert.addAction(cancelAction)
self.present(deleteAlert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3380 次 |
| 最近记录: |