zoukankan      html  css  js  c++  java
  • Swift_提醒框

    import UIKit

     

    class ViewController: UIViewController {

     

        var button : UIButton!

        var array = NSMutableArray()

        override func viewDidLoad() {

            super.viewDidLoad()

            self.view.backgroundColor = UIColor.white

            array = ["风格一","风格二","风格三"]

            creatBtn()

            

        }

        func creatBtn(){

            for i in 0..<3 {

                button = UIButton(frame: CGRect(x: 30, y: 50 + i * 60, 315, height: 30))

                button.backgroundColor = UIColor.gray

                button.tag = i

                button.setTitle(array[i] as? String, for: .normal)

                button.addTarget(self, action: #selector(remind(btn:)), for: .touchUpInside)

                self.view.addSubview(button)

            }

        

        }

        func remind(btn : UIButton){

            

            if btn.tag == 0 {

                let action = UIAlertController(title: nil, message: "选择照片", preferredStyle: .actionSheet)

                let photo = UIAlertAction(title: "相册", style: .default, handler: { action  in

                    

                })

                let camera = UIAlertAction(title: "相机", style: .default, handler: { action in

                    

                })

                let cancel = UIAlertAction(title: "取消", style: .default, handler: { action in

                    

                })

                action.addAction(photo)

                action.addAction(camera)

                action.addAction(cancel)

                self.present(action, animated: true, completion: nil)

       

            }else if btn.tag == 1{

                let action = UIAlertController(title: "提示", message: "验证码错误", preferredStyle: .alert)

                let ok = UIAlertAction(title: "确定", style: .default, handler: { action in

                

                })

                let cancel = UIAlertAction(title: "取消", style: .default, handler: { action in

                

                })

                action.addAction(ok)

                action.addAction(cancel)

                self.present(action, animated: true, completion: nil)

            }else {

                print("我是第三种风格")

                

            }

            

            

        

        }

     

        override func didReceiveMemoryWarning() {

            super.didReceiveMemoryWarning()

            // Dispose of any resources that can be recreated.

        }

     

     

    }

     

  • 相关阅读:
    Arduino mega 2560驱动安装失败(没有建立对验证码(TM)签名的目录的发布者信任)的解决方法
    Submile text3 安装使用技巧
    window.onload
    JS简单示例
    python类和对象的底层实现
    python类中方法加单下划线、双下划线、前后双下滑线的区别
    linux下json工具jq
    Django使用自定义的authentication登录认证
    django admin
    linux网卡桥接问题与docker网卡桥接问题
  • 原文地址:https://www.cnblogs.com/lcl15/p/6224641.html
Copyright © 2011-2022 走看看