diff --git a/Example/Example/RootVC.swift b/Example/Example/RootVC.swift index 8a34a89..97674ae 100644 --- a/Example/Example/RootVC.swift +++ b/Example/Example/RootVC.swift @@ -18,6 +18,7 @@ class RootVC: UIViewController { let nav = UINavigationController(rootViewController: vc) addChild(nav) view.addSubview(nav.view) + nav.navigationBar.prefersLargeTitles = true } diff --git a/Example/Example/TestGuardVC.swift b/Example/Example/TestGuardVC.swift index 2156478..709a48f 100644 --- a/Example/Example/TestGuardVC.swift +++ b/Example/Example/TestGuardVC.swift @@ -19,7 +19,7 @@ class TestGuardVC: BaseListVC { } override var titles: [String] { - return ["场景:删除菜单", "场景:升级至专业版", "场景:隐私协议页面"] + return ["场景:删除菜单", "场景:升级至专业版", "场景:隐私协议页面", "对比:原生的ActionSheet", "对比:原生Present效果"] } override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { @@ -53,6 +53,7 @@ class TestGuardVC: BaseListVC { vm.add(message: "功能1功能2...") vm.add(subTitle: "价格") vm.add(message: "只需一次性付费$2999即可永久享用。") + vm.add(message: "只需一次性付费$2999即可永久享用。") vm.add(action: .destructive, title: "购买") { [weak vc] in Alert.push(scene: .buy) { (vc) in vc.identifier = "confirm" @@ -107,7 +108,20 @@ class TestGuardVC: BaseListVC { } + } else if row == 3 { + let ac = UIAlertController(title: "Title", message: "message", preferredStyle: .actionSheet) + let ok = UIAlertAction(title: "OK", style: .default, handler: nil) + let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + ac.addAction(ok) + ac.addAction(cancel) + self.present(ac, animated: true, completion: nil) + } else if row == 4 { + let vc = UIViewController() + vc.view.backgroundColor = .white + vc.title = "ceshi" + present(vc, animated: true, completion: nil) } + } diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift index b3b7f91..d4a572f 100644 --- a/Example/Example/ViewController.swift +++ b/Example/Example/ViewController.swift @@ -7,7 +7,7 @@ // import UIKit -import ProHUD +//import ProHUD import SnapKit class ViewController: BaseListVC { diff --git a/ProHUD.xcodeproj/project.pbxproj b/ProHUD.xcodeproj/project.pbxproj index 6bc9372..9296ece 100644 --- a/ProHUD.xcodeproj/project.pbxproj +++ b/ProHUD.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 1AE9C44ABAF3F797A5518CE8 /* Pods_ProHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2011798511AD590A613E54E /* Pods_ProHUD.framework */; }; CD16490B22EF09AB0077988C /* AlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD16490A22EF09AB0077988C /* AlertModel.swift */; }; CD16490D22EF09B40077988C /* AlertConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD16490C22EF09B40077988C /* AlertConfig.swift */; }; CD16491222EF0D900077988C /* HUDView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD16491122EF0D900077988C /* HUDView.swift */; }; @@ -57,7 +56,6 @@ buildActionMask = 2147483647; files = ( CDC67BEC2490A1D100CC6FE6 /* Inspire in Frameworks */, - 1AE9C44ABAF3F797A5518CE8 /* Pods_ProHUD.framework in Frameworks */, CDC67BE92490A19100CC6FE6 /* SnapKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -431,6 +429,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.xaoxuu.ProHUD; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -458,6 +457,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.xaoxuu.ProHUD; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/ProHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ProHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata index e7d8885..919434a 100644 --- a/ProHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/ProHUD.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/ProHUD.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ProHUD.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..c867fdc --- /dev/null +++ b/ProHUD.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,25 @@ +{ + "object": { + "pins": [ + { + "package": "Inspire", + "repositoryURL": "https://github.com/xaoxuu/Inspire", + "state": { + "branch": null, + "revision": "fed13e3530ca38f884d190ea5c7b12b8f3b2a41b", + "version": "2.0.0" + } + }, + { + "package": "SnapKit", + "repositoryURL": "https://github.com/SnapKit/SnapKit", + "state": { + "branch": null, + "revision": "d458564516e5676af9c70b4f4b2a9178294f1bc6", + "version": "5.0.1" + } + } + ] + }, + "version": 1 +} diff --git a/Source/Alert/AlertController.swift b/Source/Alert/AlertController.swift index 5202b6c..d3d51ef 100644 --- a/Source/Alert/AlertController.swift +++ b/Source/Alert/AlertController.swift @@ -94,6 +94,11 @@ public extension Alert { window.makeKeyAndVisible() window.resignKey() window.addSubview(view) + if #available(iOS 13.0, *) { + window.windowScene = cfg.windowScene + } else { + // Fallback on earlier versions + } view.transform = .init(scaleX: 1.2, y: 1.2) view.alpha = 0 UIView.animateForAlertBuildIn { @@ -153,7 +158,7 @@ public extension Alert { if flag { DispatchQueue.main.async { let ani = CABasicAnimation(keyPath: "transform.rotation.z") - ani.toValue = Double.pi * 2.0 + ani.toValue = -Double.pi * 2.0 ani.duration = 3 ani.repeatCount = 10000 self.imageView?.layer.add(ani, forKey: "rotationAnimation") diff --git a/Source/Guard/GuardController.swift b/Source/Guard/GuardController.swift index de9a1e8..9f55281 100644 --- a/Source/Guard/GuardController.swift +++ b/Source/Guard/GuardController.swift @@ -232,7 +232,8 @@ internal extension Guard { if #available(iOS 11.0, *) { let count = textStack.arrangedSubviews.count if count > 1 { - textStack.setCustomSpacing(cfg.guard.margin * 2, after: textStack.arrangedSubviews[count-2]) + textStack.setCustomSpacing(cfg.guard.margin * 3, after: textStack.arrangedSubviews[count-2]) + textStack.setCustomSpacing(cfg.guard.margin * 1.5, after: textStack.arrangedSubviews[count-1]) } } else { // Fallback on earlier versions diff --git a/Source/HUDConfig.swift b/Source/HUDConfig.swift index 340be1c..115d512 100644 --- a/Source/HUDConfig.swift +++ b/Source/HUDConfig.swift @@ -8,6 +8,9 @@ import UIKit +@available(iOS 13.0, *) +public var sharedWindowScene: UIWindowScene? + public extension ProHUD { struct Configuration { @@ -17,20 +20,32 @@ public extension ProHUD { /// 根控制器 public var rootViewController: UIViewController? + @available(iOS 13.0, *) + + /// Xcode11 创建的基于 windowScene 的应用必须设置此值 + public var windowScene: UIWindowScene? { + set { + sharedWindowScene = newValue + } + get { + return sharedWindowScene + } + } + /// 动态颜色(适配iOS13) public lazy var dynamicColor: UIColor = { -// if #available(iOS 13.0, *) { -// let color = UIColor { (traitCollection: UITraitCollection) -> UIColor in -// if traitCollection.userInterfaceStyle == .dark { -// return .init(white: 1, alpha: 1) -// } else { -// return .init(white: 0.1, alpha: 1) -// } -// } -// return color -// } else { -// // Fallback on earlier versions -// } + if #available(iOS 13.0, *) { + let color = UIColor { (traitCollection: UITraitCollection) -> UIColor in + if traitCollection.userInterfaceStyle == .dark { + return .init(white: 1, alpha: 1) + } else { + return .init(white: 0.1, alpha: 1) + } + } + return color + } else { + // Fallback on earlier versions + } return .init(white: 0.1, alpha: 1) }() @@ -87,8 +102,7 @@ internal var createBlurView: () -> UIVisualEffectView = { return { let vev = UIVisualEffectView() if #available(iOS 13.0, *) { -// vev.effect = UIBlurEffect(style: .systemMaterial) - vev.effect = UIBlurEffect(style: .extraLight) + vev.effect = UIBlurEffect(style: .systemMaterial) } else if #available(iOS 11.0, *) { vev.effect = UIBlurEffect(style: .extraLight) } else { diff --git a/Source/ProHUD.xcassets/ProHUDError.imageset/Contents.json b/Source/ProHUD.xcassets/ProHUDError.imageset/Contents.json index 48c2c50..c6fbfc7 100644 --- a/Source/ProHUD.xcassets/ProHUDError.imageset/Contents.json +++ b/Source/ProHUD.xcassets/ProHUDError.imageset/Contents.json @@ -5,18 +5,18 @@ "scale" : "1x" }, { + "filename" : "fail@2x.png", "idiom" : "universal", - "filename" : "ProHUDError@2x.png", "scale" : "2x" }, { + "filename" : "fail@3x.png", "idiom" : "universal", - "filename" : "ProHUDError@3x.png", "scale" : "3x" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/Source/ProHUD.xcassets/ProHUDError.imageset/ProHUDError@2x.png b/Source/ProHUD.xcassets/ProHUDError.imageset/ProHUDError@2x.png deleted file mode 100644 index 62e1a32..0000000 Binary files a/Source/ProHUD.xcassets/ProHUDError.imageset/ProHUDError@2x.png and /dev/null differ diff --git a/Source/ProHUD.xcassets/ProHUDError.imageset/ProHUDError@3x.png b/Source/ProHUD.xcassets/ProHUDError.imageset/ProHUDError@3x.png deleted file mode 100644 index 5076022..0000000 Binary files a/Source/ProHUD.xcassets/ProHUDError.imageset/ProHUDError@3x.png and /dev/null differ diff --git a/Source/ProHUD.xcassets/ProHUDError.imageset/fail@2x.png b/Source/ProHUD.xcassets/ProHUDError.imageset/fail@2x.png new file mode 100644 index 0000000..5918b6b Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDError.imageset/fail@2x.png differ diff --git a/Source/ProHUD.xcassets/ProHUDError.imageset/fail@3x.png b/Source/ProHUD.xcassets/ProHUDError.imageset/fail@3x.png new file mode 100644 index 0000000..490bc00 Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDError.imageset/fail@3x.png differ diff --git a/Source/ProHUD.xcassets/ProHUDLoading.imageset/Contents.json b/Source/ProHUD.xcassets/ProHUDLoading.imageset/Contents.json index eba4d3a..cbb01e1 100644 --- a/Source/ProHUD.xcassets/ProHUDLoading.imageset/Contents.json +++ b/Source/ProHUD.xcassets/ProHUDLoading.imageset/Contents.json @@ -5,18 +5,50 @@ "scale" : "1x" }, { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "loading@2x.png", "idiom" : "universal", - "filename" : "ProHUDLoading@2x.png", "scale" : "2x" }, { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "loading_dark@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "loading@3x.png", + "idiom" : "universal", + "scale" : "3x" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "loading_dark@3x.png", "idiom" : "universal", - "filename" : "ProHUDLoading@3x.png", "scale" : "3x" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/Source/ProHUD.xcassets/ProHUDLoading.imageset/ProHUDLoading@2x.png b/Source/ProHUD.xcassets/ProHUDLoading.imageset/ProHUDLoading@2x.png deleted file mode 100644 index 2f37d01..0000000 Binary files a/Source/ProHUD.xcassets/ProHUDLoading.imageset/ProHUDLoading@2x.png and /dev/null differ diff --git a/Source/ProHUD.xcassets/ProHUDLoading.imageset/ProHUDLoading@3x.png b/Source/ProHUD.xcassets/ProHUDLoading.imageset/ProHUDLoading@3x.png deleted file mode 100644 index 2e7513f..0000000 Binary files a/Source/ProHUD.xcassets/ProHUDLoading.imageset/ProHUDLoading@3x.png and /dev/null differ diff --git a/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading@2x.png b/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading@2x.png new file mode 100644 index 0000000..a0974f4 Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading@2x.png differ diff --git a/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading@3x.png b/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading@3x.png new file mode 100644 index 0000000..d53953a Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading@3x.png differ diff --git a/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading_dark@2x.png b/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading_dark@2x.png new file mode 100644 index 0000000..6cf77b8 Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading_dark@2x.png differ diff --git a/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading_dark@3x.png b/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading_dark@3x.png new file mode 100644 index 0000000..e696a8b Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDLoading.imageset/loading_dark@3x.png differ diff --git a/Source/ProHUD.xcassets/ProHUDSuccess.imageset/Contents.json b/Source/ProHUD.xcassets/ProHUDSuccess.imageset/Contents.json index bff012c..01a29e9 100644 --- a/Source/ProHUD.xcassets/ProHUDSuccess.imageset/Contents.json +++ b/Source/ProHUD.xcassets/ProHUDSuccess.imageset/Contents.json @@ -5,18 +5,18 @@ "scale" : "1x" }, { + "filename" : "success@2x.png", "idiom" : "universal", - "filename" : "ProHUDSuccess@2x.png", "scale" : "2x" }, { + "filename" : "success@3x.png", "idiom" : "universal", - "filename" : "ProHUDSuccess@3x.png", "scale" : "3x" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/Source/ProHUD.xcassets/ProHUDSuccess.imageset/ProHUDSuccess@2x.png b/Source/ProHUD.xcassets/ProHUDSuccess.imageset/ProHUDSuccess@2x.png deleted file mode 100644 index 91a86c6..0000000 Binary files a/Source/ProHUD.xcassets/ProHUDSuccess.imageset/ProHUDSuccess@2x.png and /dev/null differ diff --git a/Source/ProHUD.xcassets/ProHUDSuccess.imageset/ProHUDSuccess@3x.png b/Source/ProHUD.xcassets/ProHUDSuccess.imageset/ProHUDSuccess@3x.png deleted file mode 100644 index 3b637da..0000000 Binary files a/Source/ProHUD.xcassets/ProHUDSuccess.imageset/ProHUDSuccess@3x.png and /dev/null differ diff --git a/Source/ProHUD.xcassets/ProHUDSuccess.imageset/success@2x.png b/Source/ProHUD.xcassets/ProHUDSuccess.imageset/success@2x.png new file mode 100644 index 0000000..1730567 Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDSuccess.imageset/success@2x.png differ diff --git a/Source/ProHUD.xcassets/ProHUDSuccess.imageset/success@3x.png b/Source/ProHUD.xcassets/ProHUDSuccess.imageset/success@3x.png new file mode 100644 index 0000000..72340b0 Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDSuccess.imageset/success@3x.png differ diff --git a/Source/ProHUD.xcassets/ProHUDWarning.imageset/Contents.json b/Source/ProHUD.xcassets/ProHUDWarning.imageset/Contents.json index 31d0029..a0f7a31 100644 --- a/Source/ProHUD.xcassets/ProHUDWarning.imageset/Contents.json +++ b/Source/ProHUD.xcassets/ProHUDWarning.imageset/Contents.json @@ -5,18 +5,18 @@ "scale" : "1x" }, { + "filename" : "warning@2x.png", "idiom" : "universal", - "filename" : "ProHUDWarning@2x.png", "scale" : "2x" }, { + "filename" : "warning@3x.png", "idiom" : "universal", - "filename" : "ProHUDWarning@3x.png", "scale" : "3x" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/Source/ProHUD.xcassets/ProHUDWarning.imageset/ProHUDWarning@2x.png b/Source/ProHUD.xcassets/ProHUDWarning.imageset/ProHUDWarning@2x.png deleted file mode 100644 index 9d63015..0000000 Binary files a/Source/ProHUD.xcassets/ProHUDWarning.imageset/ProHUDWarning@2x.png and /dev/null differ diff --git a/Source/ProHUD.xcassets/ProHUDWarning.imageset/ProHUDWarning@3x.png b/Source/ProHUD.xcassets/ProHUDWarning.imageset/ProHUDWarning@3x.png deleted file mode 100644 index 036ebde..0000000 Binary files a/Source/ProHUD.xcassets/ProHUDWarning.imageset/ProHUDWarning@3x.png and /dev/null differ diff --git a/Source/ProHUD.xcassets/ProHUDWarning.imageset/warning@2x.png b/Source/ProHUD.xcassets/ProHUDWarning.imageset/warning@2x.png new file mode 100644 index 0000000..fd95fdc Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDWarning.imageset/warning@2x.png differ diff --git a/Source/ProHUD.xcassets/ProHUDWarning.imageset/warning@3x.png b/Source/ProHUD.xcassets/ProHUDWarning.imageset/warning@3x.png new file mode 100644 index 0000000..ba5d643 Binary files /dev/null and b/Source/ProHUD.xcassets/ProHUDWarning.imageset/warning@3x.png differ diff --git a/Source/Toast/ToastController.swift b/Source/Toast/ToastController.swift index 84d3f9c..4499e46 100644 --- a/Source/Toast/ToastController.swift +++ b/Source/Toast/ToastController.swift @@ -111,6 +111,11 @@ public extension Toast { if self.window == nil { let w = UIWindow(frame: .zero) self.window = w + if #available(iOS 13.0, *) { + w.windowScene = cfg.windowScene + } else { + // Fallback on earlier versions + } w.windowLevel = UIWindow.Level(5000) w.backgroundColor = .clear w.layer.shadowRadius = 8 @@ -182,7 +187,7 @@ public extension Toast { if flag { DispatchQueue.main.async { let ani = CABasicAnimation(keyPath: "transform.rotation.z") - ani.toValue = Double.pi * 2.0 + ani.toValue = -Double.pi * 2.0 ani.duration = 3 ani.repeatCount = 10000 self.imageView.layer.add(ani, forKey: "rotationAnimation")