iOS_UI_弹窗_14SCLAlertView


请添加图片描述

请添加图片描述

请添加图片描述

platform :ios, '13.0'
use_frameworks!

target 'DemoApp' do
    source 'https://github.com/CocoaPods/Specs.git'
    pod 'SCLAlertView'
end

1. 弹窗——各种提示窗

import UIKit
import SCLAlertView //
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Test UI:
        let popup = UIButton(frame: CGRect(x: 0, y: 0, width: 320, height: 40))
        popup.center = self.view.center
        popup.backgroundColor = UIColor.orange
        popup.setTitle("Popup", for: .normal)
        popup.titleLabel?.font = .systemFont(ofSize: 24)
        popup.addTarget(self, action: #selector(yeBtn), for: .touchUpInside)
        self.view.backgroundColor = UIColor.orange
        self.view.addSubview(popup)
    }
    
    @objc func yeBtn(){
        //yeTye1()
        //yeTye2()
        //yeTye3()
        yeTye4()
    }
 
    func yeTye1(){
        // 1.
        SCLAlertView().showInfo("Important info", subTitle: "You are great")
    }
    
    // 重新设置标题和子标题:
    func yeTye2(){
        // 2. 初始化,设置标题和子标题:  (类型: 成功图标)
        let alertViewResponder: SCLAlertViewResponder = SCLAlertView().showSuccess("Hello World", subTitle: "This is a more descriptive text.")
        
        // 重新设置标题和子标题:
        alertViewResponder.setTitle("New Title")
        alertViewResponder.setSubTitle("New description")
    }
    
    // 各种类型:
    func yeTye3(){
        // 3.
        SCLAlertView().showError("Hello Error", subTitle: "This is a more descriptive error text.")
        
        // 4.
        SCLAlertView().showNotice("Hello Notice", subTitle: "This is a more descriptive notice text.")
        
        // 5.
        SCLAlertView().showWarning("Hello Warning", subTitle: "This is a more descriptive warning text.")
        
        // 6.
        SCLAlertView().showInfo("Hello Info", subTitle: "This is a more descriptive info text.")
        
        // 7.
        SCLAlertView().showEdit("Hello Edit", subTitle: "This is a more descriptive info text.")
    }
}

2. 弹窗——自定义、添加输出框

    // 回调: timeoutValue: 3 : 3s后自动关闭窗口,并回调:
    func yeTye4(){
        // 8.
        SCLAlertView().showTitle( "Congratulations",
            subTitle: "Operation successfully completed.",
            timeout: SCLAlertView.SCLTimeoutConfiguration(timeoutValue: 15, timeoutAction: {
                print("---回调: 关闭窗口,Operation successfully completed.")
            }),
            completeText: "Done", //标题;
            style: .success,       // 样式;
            colorStyle: 0xA429FF, // 窗口颜色;
            colorTextButton: 0xFFFFFF //Btn颜色;
        )
    }
 // 自定义:
    func yeTye5(){
        // 定义样式: 设置各字体:
        let appearance = SCLAlertView.SCLAppearance(
            kTitleFont: UIFont(name: "HelveticaNeue", size: 20)!,
            kTextFont: UIFont(name: "HelveticaNeue", size: 14)!,
            kButtonFont: UIFont(name: "HelveticaNeue-Bold", size: 14)!,
            showCloseButton: false // 不显示 关闭Btn ;
        )
        
        // 根据 样式 初始化窗口:
        let alert = SCLAlertView(appearance: appearance)
        // 显示弹窗:
        alert.showNotice("Hello Notice", subTitle: "This is a more descriptive notice text.")
    }
 func yeTye6(){
        let alertView = SCLAlertView()
        
        // 添加一个Btn,并绑定点击事件:
        alertView.addButton("First Button", target:self, selector:Selector(("firstButton")))
        
        // 添加一个Btn,并绑定点击事件的 闭包:
        alertView.addButton("Second Button"){
            print("---点击了第二个Btn,Second button tapped")
        }
        
        // 显示:
        alertView.showSuccess("Button View", subTitle: "This alert view has buttons")
    }
// 自定义图片: (顶部的圆形图标)
    func yeTye7(){
        // 初始化 一个 外观样式:
        let appearance = SCLAlertView.SCLAppearance(
            showCircularIcon: true //不显示 关闭Btn;
        )
        
        // 初始化显示弹窗:
        let alertView = SCLAlertView(appearance: appearance)
        let alertViewIcon = UIImage(named: "Camera")
        alertView.showInfo("Custom icon", subTitle: "This is a nice alert with a custom icon you choose", circleIconImage: alertViewIcon)
    }
    
 func yeTye8(){
        let alert = SCLAlertView()
        
        // 往弹窗中 添加一个 输入框:
        let txt = alert.addTextField("Enter your name") // 输入框(提示占位符);
        
        // 往弹窗中 添加一个Btn,及点击事件的闭包:
        alert.addButton("Show Name") {
            print("---上面 输入框中的内容, Text value: \(txt.text ?? "") --")
        }
        
        // 显示弹窗:
        alert.showEdit("Edit View", subTitle: "This alert view shows a text box")
    }
    
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1024app_ios_2.3.4是一款专为iOS设备设计的应用程序,其版本号为2.3.4。该应用程序在功能上提供了丰富的内容和服务,可以满足用户在不同方面的需求。 1024app_ios_2.3.4首先具备了强大的应用市场功能,用户可以通过该应用程序方便地浏览和搜索各种类型的应用,包括游戏、社交媒体、工具类等。用户可以根据自己的兴趣和需求下载和安装这些应用,并在手机上进行使用。 其次,1024app_ios_2.3.4还提供了个性化推荐功能,根据用户的使用习惯和喜好,推荐适合用户的应用程序。这样,用户可以更加高效地发现和使用他们感兴趣的应用,提高了用户体验。 另外,1024app_ios_2.3.4还支持应用的更新和升级。用户可以在应用程序中获得关于已安装应用的最新版本信息,并进行更新。这样,用户可以及时获得应用程序的最新功能和修复bug,提高了应用的稳定性和安全性。 最后,1024app_ios_2.3.4还具备了一些额外的功能,例如用户可以在应用中进行应用评分和评论,与其他用户交流和分享使用心得。此外,用户还可以通过该应用程序获取关于应用的详细信息,如应用的大小、开发者介绍等。 综上所述,1024app_ios_2.3.4是一款功能强大的iOS应用程序,用户可以在其中浏览和下载各种类型的应用,享受个性化推荐、应用更新和升级等服务。同时,用户还可以与其他用户互动交流,获取应用的详细信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值