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, width: 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.

    }

 

 

}

 

转载于:https://www.cnblogs.com/lcl15/p/6224641.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值