iOS_第三方1_弹窗_动态提示效果_12SweetAlert

请添加图片描述
请添加图片描述
请添加图片描述

  • 2
    请添加图片描述

请添加图片描述

请添加图片描述
请添加图片描述

import UIKit
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Test Btn:
        let popup = UIButton(frame: CGRect(x: 0, y: 0, width: 280, height: 40))
        popup.center = self.view.center
        popup.titleLabel?.font = .systemFont(ofSize: 24)
        popup.backgroundColor = UIColor.orange
        popup.setTitle("Show sweet alert", for: .normal)
        popup.addTarget(self, action: #selector(showSweetAlert(_:)), for: .touchUpInside)
        self.view.backgroundColor = UIColor.orange
        self.view.addSubview(popup)
    }
    @objc func showSweetAlert(_ sender: AnyObject){
        yeTye()
    }
    
    // 弹窗:
    func yeTye(){
        //1.
        _ = SweetAlert().showAlert("Here's a message!")
            
        // 2.  设置样式 style: AlertStyle.none
        //_ = SweetAlert().showAlert("Here's a message!", subTitle: "It's pretty, isn't it?", style: AlertStyle.none)
                
        //3.
        //_ = SweetAlert().showAlert("Good job!", subTitle: "You clicked the button!", style: AlertStyle.success)
    }
}

-2

 // 2. 自定义 弹窗:
    func yeTye2(){
        // 1.  带多个Btn 得弹窗:
        let title = "Are you sure?"
        let subTitle = "Your file will be permanently delete!"
        let alertStyle = AlertStyle.warning // 样式;

        // 两个Btn:
        let buttonTitle = "Cancel"
        let buttonColor = UIColor.lightGray

        let otherButtonnTitle = "Yes, delete it!"
        let otherButtonColor = UIColor.colorFromRGB(0xDD6B55)

        // 初始化 弹窗: 设置相应的属性:
        SweetAlert().showAlert(title,
                   subTitle: subTitle,
                   style: alertStyle,
                   buttonTitle: buttonTitle,
                   buttonColor: buttonColor,
                   otherButtonTitle: otherButtonnTitle,
                   otherButtonColor: otherButtonColor)
        { (isOtherButton) -> Void in
            if isOtherButton == true { // 点击了 第二个Btn:
                // 新的弹窗:
                _ = SweetAlert().showAlert("Cancelled!", subTitle: "Your imaginary file is safe", style: AlertStyle.error)
            } else {
                // 点击了第一个Btn:
                // 新的弹窗:
                _ = SweetAlert().showAlert("Deleted!", subTitle: "Your imaginary file has been deleted!", style: AlertStyle.success)
            }
        }
    }

    // 3. 自定义图片 弹窗:
    func yeTye3(){
        _ = SweetAlert().showAlert("Sweet!",
                           subTitle: "Here's a custom image.",
                           style: .customImage(imageFile: "coffee.png"))
        // coffee.png : 项目 本地的图片;
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值