我是靠谱客的博主 积极大神,最近开发中收集的这篇文章主要介绍iOS(6) 有关于alertcontroller的一些事情iOS(6) 有关于alertcontroller的一些事情,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

iOS(6) 有关于alertcontroller的一些事情

所有的alert都要有的

present(alert, animated: true, completion: nil)

actionsheet

@IBAction func actionSheet(_ sender: Any) {
        let alert = UIAlertController(title: "action sheet", message: "this is an ation sheet", preferredStyle: .actionSheet)
        alert.addAction(UIAlertAction(title: "RED", style: .default, handler: { (action) in
            print("ok clicked")
            self.view.backgroundColor = UIColor.red
        }))
        alert.addAction(UIAlertAction(title: "Green", style: .destructive, handler: { (action) in
            print("destructive clicked")
            self.view.backgroundColor = UIColor.green
     }))
        alert.addAction(UIAlertAction(title: "White", style: .cancel, handler: { (action) in
            print("cancel clicked")
            self.view.backgroundColor = UIColor.white
        }))
        
        present(alert, animated: true, completion: nil)
        
    }

最厚的效果
在这里插入图片描述

alert对话框中弹出登陆表单

@IBAction func login(_ sender: Any) {
        let alert = UIAlertController(title: "Login", message: "Please input your personal information", preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "Login", style: .default, handler: { (action) in
            if let userNameTextField = alert.textFields?.first, let passWordTextField = alert.textFields?.last {
                print("username:(userNameTextField.text!) password:(passWordTextField.text!)")
            }
        }))
        alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) in
        }))
        
        alert.addTextField { (textField) in
            textField.placeholder = "your user name?"
        }
        alert.addTextField { (textField) in
            textField.placeholder = "your password?"
            textField.isSecureTextEntry = true
        }
        present(alert, animated: true, completion: nil)
        
    }

在这里插入图片描述

最后

以上就是积极大神为你收集整理的iOS(6) 有关于alertcontroller的一些事情iOS(6) 有关于alertcontroller的一些事情的全部内容,希望文章能够帮你解决iOS(6) 有关于alertcontroller的一些事情iOS(6) 有关于alertcontroller的一些事情所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部