123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //
- // SBTReadLoadingVCtr.swift
- // SolarBT
- //
- // Created by weclouds on 2019/5/11.
- // Copyright © 2019 weclouds. All rights reserved.
- //
- import UIKit
- import SwiftPopup
- extension UIViewController {
- func swiftClassFromString(className: String) -> UIViewController! {
- // get the project name
- if let appName: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as! String? {
- // 过滤无效字符 空格不转换的话 得不到准确类名
- let formattedAppName = appName.replacingOccurrences(of: " ", with: "_")
- //拼接控制器名
- let classStringName = "\(formattedAppName).\(className)"
- //将控制名转换为类
- let classType = NSClassFromString(classStringName) as? UIViewController.Type
- if let type = classType {
- let newVC = type.init()
- return newVC
- }
- }
- return nil;
- }
- }
- extension UIImageView {
-
- // 360度旋转图片
- func rotate360Degree() {
- log.debug("rotate360Degree --- ")
- let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation.z") // 让其在z轴旋转
- rotationAnimation.fromValue = NSNumber(value: 0) //左幅度
- rotationAnimation.toValue = NSNumber(value: .pi * 2.0) // 旋转角度
- rotationAnimation.duration = 1.2 // 旋转周期
- rotationAnimation.isCumulative = true // 旋转累加角度
- rotationAnimation.repeatCount = HUGE // 旋转次数
- layer.add(rotationAnimation, forKey: "rotationAnimation")
- }
-
- // 停止旋转
- func stopRotate() {
- layer.removeAllAnimations()
- }
- }
- class SBTReadLoadingVCtr: SwiftPopup {
- var message :String?{
- didSet{
-
- }
- }
-
- var deviceName: String?
- @IBOutlet weak var deviceNameLabel: UILabel!
- @IBOutlet weak var messageLabel: UILabel!
- @IBOutlet weak var loadingImageV: UIImageView!
-
- @IBOutlet weak var backBtn: UIButton!
- @IBOutlet weak var box: UIView!
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- box.layer.masksToBounds = true
- box.layer.cornerRadius = 5
- self.messageLabel.text = self.message
- self.deviceNameLabel.text = self.deviceName
-
- backBtn.setTitle("Back".da_localizedStr(), for: .normal)
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- loadingImageV.rotate360Degree()
- }
-
-
- override func viewDidAppear(_ animated: Bool) {
- super.viewDidAppear(animated)
- }
- open func dismiss(_ delay : TimeInterval) {
- self.perform(#selector(close), with: nil, afterDelay: delay)
-
-
- }
-
- @objc func close() {
- self.dismiss()
- // loadingImageV.stopRotate()
- }
- }
|