兼容Xcode11+iOS13应用

This commit is contained in:
xaoxuu 2020-06-15 15:11:44 +08:00
parent 3715c1445d
commit d4d0dd346a
32 changed files with 139 additions and 42 deletions

View File

@ -18,6 +18,7 @@ class RootVC: UIViewController {
let nav = UINavigationController(rootViewController: vc)
addChild(nav)
view.addSubview(nav.view)
nav.navigationBar.prefersLargeTitles = true
}

View File

@ -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)
}
}

View File

@ -7,7 +7,7 @@
//
import UIKit
import ProHUD
//import ProHUD
import SnapKit
class ViewController: BaseListVC {

View File

@ -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";
};

View File

@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "self:ProHUD.xcodeproj">
location = "self:">
</FileRef>
</Workspace>

View File

@ -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
}

View File

@ -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")

View File

@ -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

View File

@ -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 {

View File

@ -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
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -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
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -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
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -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
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -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")