从后台恢复时恢复动画;更新资源图片

This commit is contained in:
xaoxuu 2020-06-19 19:13:33 +08:00
parent 3f384becef
commit d32d6f2dbe
102 changed files with 519 additions and 206 deletions

Binary file not shown.

View File

@ -76,21 +76,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
} }
extension ProHUD.Scene { extension ProHUD.Scene {
static var confirm: ProHUD.Scene {
var scene = ProHUD.Scene(identifier: "confirm")
scene.image = UIImage(named: "ProHUDMessage")
return scene
}
static var delete: ProHUD.Scene { static var delete: ProHUD.Scene {
var scene = ProHUD.Scene(identifier: "delete") var scene = ProHUD.Scene(identifier: "delete")
scene.image = UIImage(named: "ProHUDTrash") scene.image = UIImage(named: "prohud.trash")
scene.title = "确认删除" scene.title = "确认删除"
scene.message = "此操作不可撤销" scene.message = "此操作不可撤销"
return scene return scene
} }
static var buy: ProHUD.Scene { static var buy: ProHUD.Scene {
var scene = ProHUD.Scene(identifier: "buy") var scene = ProHUD.Scene(identifier: "buy")
scene.image = UIImage(named: "ProHUDBuy") scene.image = UIImage(named: "alert.buy")
scene.title = "确认付款" scene.title = "确认付款"
scene.message = "一旦购买拒不退款" scene.message = "一旦购买拒不退款"
return scene return scene

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1,22 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ProHUDMessage@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ProHUDMessage@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -1,22 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ProHUDTrash@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ProHUDTrash@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@ -5,12 +5,12 @@
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "fail@2x.png", "filename" : "prohud.candy@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "fail@3x.png", "filename" : "prohud.candy@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.checkmark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.checkmark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.exclamationmark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.exclamationmark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.message@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.message@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -5,12 +5,12 @@
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "矩形@2x.png", "filename" : "prohud.note@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "矩形@3x.png", "filename" : "prohud.note@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.privacy@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.privacy@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.questionmark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.questionmark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -5,12 +5,12 @@
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "success@2x.png", "filename" : "prohud.trash@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "success@3x.png", "filename" : "prohud.trash@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.windmill@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.windmill@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.xmark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.xmark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14835.7" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ttk-4w-IeX"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ttk-4w-IeX">
<device id="retina6_1" orientation="portrait" appearance="light"/> <device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14790.5"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
@ -11,10 +11,17 @@
<!--ProHUD--> <!--ProHUD-->
<scene sceneID="tne-QT-ifu"> <scene sceneID="tne-QT-ifu">
<objects> <objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController"> <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="ProHUD_老项目" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RLL-Jl-KUu">
<rect key="frame" x="168" y="377" width="78" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button" image="icloud.and.arrow.down" catalog="system"/>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view> </view>
@ -43,4 +50,7 @@
<point key="canvasLocation" x="140.57971014492756" y="133.92857142857142"/> <point key="canvasLocation" x="140.57971014492756" y="133.92857142857142"/>
</scene> </scene>
</scenes> </scenes>
<resources>
<image name="icloud.and.arrow.down" catalog="system" width="128" height="112"/>
</resources>
</document> </document>

View File

@ -23,7 +23,7 @@ class TestAlertVC: BaseListVC {
"场景同步成功写法2", "场景同步成功写法2",
"场景:同步失败和重试", "场景:同步失败和重试",
"极端场景:短时间内调用了多次同一个弹窗", "极端场景:短时间内调用了多次同一个弹窗",
"极端场景:多个弹窗重叠", "极端场景:多个不同的弹窗重叠",
"测试较长的标题和内容", "测试较长的标题和内容",
"测试特别长的标题和内容"] "测试特别长的标题和内容"]
} }
@ -45,10 +45,8 @@ class TestAlertVC: BaseListVC {
t?.pop() t?.pop()
f() f()
} }
self?.simulateSync()
} }
} }
simulateSync()
} }
f() f()
} else if row == 1 { } else if row == 1 {

View File

@ -29,7 +29,7 @@ class TestGuardVC: BaseListVC {
Guard.push() { (vc) in Guard.push() { (vc) in
vc.update { (vm) in vc.update { (vm) in
vm.add(action: .destructive, title: "删除") { [weak vc] in vm.add(action: .destructive, title: "删除") { [weak vc] in
Alert.push(scene: .delete, title: "确认删除", message: "此操作不可撤销") { (vc) in Alert.push(scene: .delete) { (vc) in
vc.update { (vm) in vc.update { (vm) in
vm.add(action: .destructive, title: "删除") { [weak vc] in vm.add(action: .destructive, title: "删除") { [weak vc] in
vc?.pop() vc?.pop()

View File

@ -29,6 +29,7 @@ class TestToastVC: BaseListVC {
"根据id查找并修改实例", "根据id查找并修改实例",
"测试较长的标题和内容", "测试较长的标题和内容",
"测试特别长的标题和内容", "测试特别长的标题和内容",
"测试只有title",
"测试只有message"] "测试只有message"]
} }
@ -62,7 +63,12 @@ class TestToastVC: BaseListVC {
} else if row == 4 { } else if row == 4 {
Toast.push(scene: .default, title: "传入指定图标测试", message: "这是消息内容") { (vc) in Toast.push(scene: .default, title: "传入指定图标测试", message: "这是消息内容") { (vc) in
vc.update { (vm) in vc.update { (vm) in
vm.icon = UIImage(named: "icon_download") if #available(iOS 13.0, *) {
vc.imageView.tintColor = .brown
vm.icon = UIImage(systemName: "icloud.and.arrow.down")
} else {
vm.icon = UIImage(named: "icloud.and.arrow.down")
}
} }
} }
} else if row == 5 { } else if row == 5 {
@ -73,7 +79,7 @@ class TestToastVC: BaseListVC {
} }
} }
} else if row == 6 { } else if row == 6 {
Toast.push(scene: .default, title: "好友邀请", message: "你收到一条好友邀请,点击查看详情。", duration: 10) { (vc) in Toast.push(scene: .message, title: "好友邀请", message: "你收到一条好友邀请,点击查看详情。", duration: 10) { (vc) in
vc.identifier = "xxx" vc.identifier = "xxx"
vc.didTapped { [weak vc] in vc.didTapped { [weak vc] in
vc?.pop() vc?.pop()
@ -117,7 +123,6 @@ class TestToastVC: BaseListVC {
} else if row == 9 { } else if row == 9 {
Toast.push() { (a) in Toast.push() { (a) in
a.update { (vm) in a.update { (vm) in
vm.scene = .warning
vm.title = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过" vm.title = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
vm.message = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过" vm.message = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
@ -126,7 +131,6 @@ class TestToastVC: BaseListVC {
} else if row == 10 { } else if row == 10 {
Toast.push() { (a) in Toast.push() { (a) in
a.update { (vm) in a.update { (vm) in
vm.scene = .warning
vm.title = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过" vm.title = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
vm.message = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过" vm.message = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
@ -136,15 +140,23 @@ class TestToastVC: BaseListVC {
Toast.push() { (a) in Toast.push() { (a) in
a.update { (vm) in a.update { (vm) in
vm.scene = .warning vm.scene = .warning
vm.message = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过" vm.title = "正在同步看到了你撒地"
} }
} }
} } else if row == 12 {
Toast.push() { (a) in
a.update { (vm) in
vm.scene = .warning
vm.message = "正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过正在同步看到了你撒地方快乐撒的肌肤轮廓啊就是;来的跨省的人格人格离开那地方离开过"
}
}
}
} }
func simulateSync() { func simulateSync() {
DispatchQueue.main.asyncAfter(deadline: .now() + 5) { DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
Toast.find("loading", last: { (t) in Toast.find("loading", last: { (t) in
t.update { (vm) in t.update { (vm) in
vm.scene = .success vm.scene = .success

View File

@ -10,6 +10,10 @@ import UIKit
import SnapKit import SnapKit
import Inspire import Inspire
public extension UIWindow.Level {
static let proAlert = UIWindow.Level.alert - 1
}
public extension ProHUD.Configuration { public extension ProHUD.Configuration {
struct Alert { struct Alert {
// MARK: // MARK:
@ -112,23 +116,20 @@ fileprivate var privUpdateImage: (ProHUD.Alert) -> Void = {
return { (vc) in return { (vc) in
let config = cfg.alert let config = cfg.alert
let img = vc.vm.icon ?? vc.vm.scene.image let img = vc.vm.icon ?? vc.vm.scene.image
if let imgv = vc.imageView { vc.imageView.image = img
imgv.image = img vc.contentStack.addArrangedSubview(vc.imageView)
} else { vc.imageView.contentMode = .scaleAspectFit
let icon = UIImageView(image: img) vc.imageView.snp.makeConstraints { (mk) in
vc.contentStack.addArrangedSubview(icon) mk.top.greaterThanOrEqualTo(vc.contentView).offset(config.padding*2.25)
icon.contentMode = .scaleAspectFit mk.bottom.lessThanOrEqualTo(vc.contentView).offset(-config.padding*2.25)
icon.snp.makeConstraints { (mk) in mk.leading.greaterThanOrEqualTo(vc.contentView).offset(config.padding*4)
mk.top.greaterThanOrEqualTo(vc.contentView).offset(config.padding*2.25) mk.trailing.lessThanOrEqualTo(vc.contentView).offset(-config.padding*4)
mk.bottom.lessThanOrEqualTo(vc.contentView).offset(-config.padding*2.25) mk.width.equalTo(config.iconSize.width)
mk.leading.greaterThanOrEqualTo(vc.contentView).offset(config.padding*4) mk.height.equalTo(config.iconSize.height)
mk.trailing.lessThanOrEqualTo(vc.contentView).offset(-config.padding*4)
mk.width.equalTo(config.iconSize.width)
mk.height.equalTo(config.iconSize.height)
}
vc.imageView = icon
} }
vc.imageView?.layer.removeAllAnimations() vc.imageView.layer.removeAllAnimations()
vc.animateLayer = nil
vc.animation = nil
} }
}() }()
@ -298,10 +299,10 @@ fileprivate var privReloadData: (ProHUD.Alert) -> Void = {
// //
if isFirstLayout { if isFirstLayout {
vc.view.layoutIfNeeded() vc.view.layoutIfNeeded()
vc.imageView?.transform = .init(scaleX: 0.75, y: 0.75) vc.imageView.transform = .init(scaleX: 0.75, y: 0.75)
UIView.animateForAlert { UIView.animateForAlert {
vc.view.layoutIfNeeded() vc.view.layoutIfNeeded()
vc.imageView?.transform = .identity vc.imageView.transform = .identity
} }
} else { } else {
UIView.animateForAlert { UIView.animateForAlert {

View File

@ -36,7 +36,7 @@ public extension ProHUD {
}() }()
/// ///
public var imageView: UIImageView? public var imageView = UIImageView()
/// ///
public var titleLabel: UILabel? public var titleLabel: UILabel?
@ -151,16 +151,11 @@ public extension Alert {
vm.forceQuitCallback = callback vm.forceQuitCallback = callback
} }
///
/// - Parameter flag:
func rotate(_ flag: Bool = true, direction: ProHUD.RotateDirection = .clockwise, speed: CFTimeInterval = 1) {
DispatchQueue.main.async {
self.imageView?.rotate(flag: flag, direction: direction, speed: speed)
}
}
} }
extension Alert: RotateAnimation {
}
// MARK: - // MARK: -
public extension Alert { public extension Alert {
@ -320,7 +315,7 @@ fileprivate extension Alert {
alertWindow = w alertWindow = w
w.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0) w.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0)
// alert // alert
w.windowLevel = UIWindow.Level.alert - 1 w.windowLevel = .proAlert
return w return w
} }
@ -337,7 +332,7 @@ fileprivate extension Alert {
} else if alerts.count == 1 { } else if alerts.count == 1 {
alerts.removeAll() alerts.removeAll()
} else { } else {
debug("漏洞已经没有alert了") debug("‼️代码漏洞已经没有alert了")
} }
} }

View File

@ -31,7 +31,7 @@ public extension Alert {
/// ///
public var icon: UIImage? { public var icon: UIImage? {
didSet { didSet {
vc?.imageView?.image = icon vc?.imageView.image = icon
} }
} }

View File

@ -120,9 +120,9 @@ public extension Guard {
return f(vc) return f(vc)
} else { } else {
// RootVC // RootVC
let ws = UIApplication.shared.windows.reversed().filter { (w) -> Bool in let ws = UIApplication.shared.windows.filter { (w) -> Bool in
// UITextEffectsWindow Window // UITextEffectsWindow Window
if "\(type(of:w))" == "UIWindow" && w.isHidden == false { if "\(type(of:w))" == "UIWindow" && w.isHidden == false && w.windowLevel == .normal {
return true return true
} else { } else {
return false return false

View File

@ -18,6 +18,10 @@ public class HUDController: UIViewController {
internal var willDisappearCallback: (() -> Void)? internal var willDisappearCallback: (() -> Void)?
internal var didDisappearCallback: (() -> Void)? internal var didDisappearCallback: (() -> Void)?
///
public var animateLayer: CALayer?
internal var animation: CAAnimation?
/// ///
internal var buttonEvents = [UIButton:() -> Void]() internal var buttonEvents = [UIButton:() -> Void]()
@ -84,3 +88,50 @@ internal extension HUDController {
} }
} }
extension HUDController {
@objc func pauseAnimation() {
if let layer = animateLayer {
animation = layer.animation(forKey: .rotateKey)
layer.timeOffset = layer.convertTime(CACurrentMediaTime(), from: nil)
layer.speed = 0
}
}
@objc func resumeAnimation() {
if let layer = animateLayer, let ani = animation, layer.speed == 0 {
let pauseTime = layer.timeOffset
layer.timeOffset = 0
let beginTime = layer.convertTime(CACurrentMediaTime(), from: nil) - pauseTime
layer.beginTime = beginTime
layer.speed = 1
layer.add(ani, forKey: .rotateKey)
}
}
}
public protocol RotateAnimation: HUDController {
var imageView: UIImageView { get }
var animateLayer: CALayer? { get set }
}
public extension RotateAnimation {
func rotate(_ layer: CALayer? = nil, direction: ProHUD.RotateDirection = .clockwise, speed: CFTimeInterval = 1) {
DispatchQueue.main.async {
let l = layer ?? self.imageView.layer
self.animateLayer = l
l.startRotate(direction: direction, speed: speed)
NotificationCenter.default.addObserver(self, selector: #selector(self.pauseAnimation), name: UIApplication.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.resumeAnimation), name: UIApplication.willEnterForegroundNotification, object: nil)
}
}
func rotate(_ layer: CALayer? = nil, _ flag: Bool) {
DispatchQueue.main.async {
self.animateLayer = nil
(layer ?? self.imageView.layer)?.endRotate()
NotificationCenter.default.removeObserver(self, name: UIApplication.didEnterBackgroundNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: UIApplication.willEnterForegroundNotification, object: nil)
}
}
}

View File

@ -31,6 +31,11 @@ public extension ProHUD {
case clockwise = 1 case clockwise = 1
case counterclockwise = -1 case counterclockwise = -1
} }
}
internal extension String {
static let rotateKey = "rotationAnimation"
} }
internal extension Alert { internal extension Alert {
@ -150,21 +155,21 @@ internal extension UIView {
animateForGuard(animations: animations, completion: nil) animateForGuard(animations: animations, completion: nil)
} }
func rotate(flag: Bool, direction: ProHUD.RotateDirection, speed: CFTimeInterval) { }
if flag == true {
if layer.animation(forKey: "rotationAnimation") == nil { extension CALayer {
let ani = CABasicAnimation(keyPath: "transform.rotation.z") func startRotate(direction: ProHUD.RotateDirection, speed: CFTimeInterval) {
ani.toValue = direction.rawValue * Double.pi * 2.0 if animation(forKey: .rotateKey) == nil {
if speed > 0 { let ani = CABasicAnimation(keyPath: "transform.rotation.z")
ani.duration = 2 / speed ani.toValue = direction.rawValue * Double.pi * 2.0
} if speed > 0 {
ani.repeatDuration = .infinity ani.duration = 2 / speed
layer.add(ani, forKey: "rotationAnimation")
} }
} else { ani.repeatDuration = .infinity
layer.removeAnimation(forKey: "rotationAnimation") add(ani, forKey: .rotateKey)
} }
} }
func endRotate() {
removeAnimation(forKey: .rotateKey)
}
} }

View File

@ -33,15 +33,19 @@ public class ProHUD {
} }
// //
public extension ProHUD.Scene { public extension ProHUD.Scene {
init(identifier: String) { init(identifier: String) {
self.init() self.init()
id = identifier id = identifier
} }
static var `default`: ProHUD.Scene { static var `default`: ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "default") var scene = ProHUD.Scene.init(identifier: "default")
scene.image = ProHUD.image(named: "prohud.note")
return scene
}
static var message: ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "message")
scene.image = ProHUD.image(named: "prohud.message") scene.image = ProHUD.image(named: "prohud.message")
return scene return scene
} }
@ -49,27 +53,48 @@ public extension ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "loading") var scene = ProHUD.Scene.init(identifier: "loading")
scene.alertDuration = 0 scene.alertDuration = 0
scene.toastDuration = 0 scene.toastDuration = 0
scene.image = ProHUD.image(named: "prohud.loading") scene.image = ProHUD.image(named: "prohud.candy")
return scene return scene
} }
static var success: ProHUD.Scene { static var success: ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "success") var scene = ProHUD.Scene.init(identifier: "success")
scene.alertDuration = 2 scene.alertDuration = 2
scene.image = ProHUD.image(named: "prohud.success") scene.image = ProHUD.image(named: "prohud.checkmark")
return scene return scene
} }
static var warning: ProHUD.Scene { static var warning: ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "warning") var scene = ProHUD.Scene.init(identifier: "warning")
scene.alertDuration = 2 scene.alertDuration = 2
scene.toastDuration = 5 scene.toastDuration = 5
scene.image = ProHUD.image(named: "prohud.warning") scene.image = ProHUD.image(named: "prohud.exclamationmark")
return scene return scene
} }
static var error: ProHUD.Scene { static var error: ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "error") var scene = ProHUD.Scene.init(identifier: "error")
scene.alertDuration = 2 scene.alertDuration = 2
scene.toastDuration = 5 scene.toastDuration = 5
scene.image = ProHUD.image(named: "prohud.error") scene.image = ProHUD.image(named: "prohud.xmark")
return scene
}
static var confirm: ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "confirm")
scene.alertDuration = 2
scene.toastDuration = 5
scene.image = ProHUD.image(named: "prohud.questionmark")
return scene
}
static var privacy: ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "privacy")
scene.alertDuration = 2
scene.toastDuration = 5
scene.image = ProHUD.image(named: "prohud.privacy")
return scene
}
static var delete: ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "delete")
scene.alertDuration = 2
scene.toastDuration = 5
scene.image = ProHUD.image(named: "prohud.trash")
return scene return scene
} }

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.candy@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.candy@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.checkmark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.checkmark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.exclamationmark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.exclamationmark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -1,54 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "loading@2x.png",
"idiom" : "universal",
"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",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -5,18 +5,18 @@
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "prohud.message@2x.png",
"idiom" : "universal", "idiom" : "universal",
"filename" : "ProHUDMessage@2x.png",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "prohud.message@3x.png",
"idiom" : "universal", "idiom" : "universal",
"filename" : "ProHUDMessage@3x.png",
"scale" : "3x" "scale" : "3x"
} }
], ],
"info" : { "info" : {
"version" : 1, "author" : "xcode",
"author" : "xcode" "version" : 1
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -5,12 +5,12 @@
"scale" : "1x" "scale" : "1x"
}, },
{ {
"filename" : "warning@2x.png", "filename" : "prohud.note@2x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "2x" "scale" : "2x"
}, },
{ {
"filename" : "warning@3x.png", "filename" : "prohud.note@3x.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "3x" "scale" : "3x"
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.privacy@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.privacy@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.questionmark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.questionmark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.trash@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.trash@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.windmill@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.windmill@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "prohud.xmark@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "prohud.xmark@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Some files were not shown because too many files have changed in this diff Show More