diff --git a/Assets/Readme/Miniature - Add.svg b/Assets/Readme/Miniature - Add.svg
index b5cd23f..8bf13fd 100644
--- a/Assets/Readme/Miniature - Add.svg
+++ b/Assets/Readme/Miniature - Add.svg
@@ -5,9 +5,9 @@
Created with Sketch.
-
-
-
+
+
+
\ No newline at end of file
diff --git a/Assets/Readme/Miniature - Moon.svg b/Assets/Readme/Miniature - Moon.svg
new file mode 100644
index 0000000..423a876
--- /dev/null
+++ b/Assets/Readme/Miniature - Moon.svg
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/Assets/Readme/Miniature - Star.svg b/Assets/Readme/Miniature - Star.svg
new file mode 100644
index 0000000..bec5ab6
--- /dev/null
+++ b/Assets/Readme/Miniature - Star.svg
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/Assets/Sketch/Presets.sketch b/Assets/Sketch/Presets.sketch
index d58ac96..9efc281 100644
Binary files a/Assets/Sketch/Presets.sketch and b/Assets/Sketch/Presets.sketch differ
diff --git a/Example/Controllers/ViewController.swift b/Example/Controllers/ViewController.swift
index 20e63be..629763c 100644
--- a/Example/Controllers/ViewController.swift
+++ b/Example/Controllers/ViewController.swift
@@ -8,6 +8,8 @@ class ViewController: UITableViewController {
Alert(key: "Heart", preset: .heart, title: "Love", subtitle: "We'll recommend more like this for you"),
Alert(key: "Doc", preset: .doc, title: "Document saved", subtitle: "See in folder new file"),
Alert(key: "Bookmark", preset: .bookmark, title: "Added to bookmark", subtitle: "See bookmarks screen"),
+ Alert(key: "Moon", preset: .moon, title: "Night Mode", subtitle: "You can disable it in settings"),
+ Alert(key: "Star", preset: .star, title: "Added to favorite", subtitle: nil),
Alert(key: "Add", preset: .add, title: "Added to Folder", subtitle: nil),
Alert(key: "Error", preset: .error, title: "Oops", subtitle: "Please try again later"),
Alert(key: "Message", preset: nil, title: nil, subtitle: "Email required")
diff --git a/Readme.md b/Readme.md
index fb3ef9c..04dd661 100644
--- a/Readme.md
+++ b/Readme.md
@@ -80,6 +80,8 @@ For now supporting `Done`, `Add`, `Heart`, `Doc`, `Error`, `Bookmark` & `Message
+
+
diff --git a/SPAlert.podspec b/SPAlert.podspec
index 79d044d..f395849 100644
--- a/SPAlert.podspec
+++ b/SPAlert.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "SPAlert"
- s.version = "2.0.5"
+ s.version = "2.0.6"
s.summary = "Native alert from Apple Music & Feedback. Contains Done, Heart & Message presets."
s.homepage = "https://github.com/IvanVorobei/SPAlert"
s.source = { :git => "https://github.com/IvanVorobei/SPAlert.git", :tag => s.version }
diff --git a/SPAlert.xcodeproj/project.pbxproj b/SPAlert.xcodeproj/project.pbxproj
index bc034d8..15b791c 100644
--- a/SPAlert.xcodeproj/project.pbxproj
+++ b/SPAlert.xcodeproj/project.pbxproj
@@ -26,6 +26,8 @@
F4A5A92C2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A5A92B2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift */; };
F4A8361A2385588300EB32E0 /* SPAlertIconDocView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4A836192385588300EB32E0 /* SPAlertIconDocView.swift */; };
F4CA67B5238ABD0100E72F79 /* SPAlertIconAddView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4CA67B4238ABD0100E72F79 /* SPAlertIconAddView.swift */; };
+ F4D3CD58238DA9FE006C3DE2 /* SPAlertIconMoonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D3CD57238DA9FE006C3DE2 /* SPAlertIconMoonView.swift */; };
+ F4D3CD5A238DAA49006C3DE2 /* SPAlertIconStarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4D3CD59238DAA49006C3DE2 /* SPAlertIconStarView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -80,6 +82,8 @@
F4A5A92B2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconBookmarkView.swift; sourceTree = ""; };
F4A836192385588300EB32E0 /* SPAlertIconDocView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconDocView.swift; sourceTree = ""; };
F4CA67B4238ABD0100E72F79 /* SPAlertIconAddView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconAddView.swift; sourceTree = ""; };
+ F4D3CD57238DA9FE006C3DE2 /* SPAlertIconMoonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconMoonView.swift; sourceTree = ""; };
+ F4D3CD59238DAA49006C3DE2 /* SPAlertIconStarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPAlertIconStarView.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -163,6 +167,8 @@
F4A836192385588300EB32E0 /* SPAlertIconDocView.swift */,
F4A5A92B2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift */,
F4CA67B4238ABD0100E72F79 /* SPAlertIconAddView.swift */,
+ F4D3CD57238DA9FE006C3DE2 /* SPAlertIconMoonView.swift */,
+ F4D3CD59238DAA49006C3DE2 /* SPAlertIconStarView.swift */,
);
path = Icons;
sourceTree = "";
@@ -364,6 +370,8 @@
F4A5A92C2388792F00B0DFE0 /* SPAlertIconBookmarkView.swift in Sources */,
F41204EC2382AC9B009C2AC7 /* SPAlertIconDoneView.swift in Sources */,
F41204E92382AC9B009C2AC7 /* SPAlertView.swift in Sources */,
+ F4D3CD58238DA9FE006C3DE2 /* SPAlertIconMoonView.swift in Sources */,
+ F4D3CD5A238DAA49006C3DE2 /* SPAlertIconStarView.swift in Sources */,
706F894A2383277500ECF5D1 /* SPAlertIconErrorView.swift in Sources */,
F41205292382AF5C009C2AC7 /* SPAlertIconAnimatable.swift in Sources */,
F4CA67B5238ABD0100E72F79 /* SPAlertIconAddView.swift in Sources */,
diff --git a/Source/SPAlert/Models/SPAlertPreset.swift b/Source/SPAlert/Models/SPAlertPreset.swift
index 832c418..e25df84 100644
--- a/Source/SPAlert/Models/SPAlertPreset.swift
+++ b/Source/SPAlert/Models/SPAlertPreset.swift
@@ -30,6 +30,8 @@ public enum SPAlertPreset {
case heart
case doc
case bookmark
+ case moon
+ case star
case add
case error
@@ -48,6 +50,10 @@ public enum SPAlertPreset {
return SPAlertIconBookmarkView()
case .add:
return SPAlertIconAddView()
+ case .moon:
+ return SPAlertIconMoonView()
+ case .star:
+ return SPAlertIconStarView()
case .error:
return SPAlertIconErrorView()
}
@@ -87,9 +93,25 @@ public enum SPAlertPreset {
layout.topSpace = 57
layout.bottomSpace = 29
layout.iconWidth = 112
- layout.iconHeight = 94
+ layout.iconHeight = 90
layout.bottomIconSpace = 36
return layout
+ case .moon:
+ var layout = SPAlertLayout()
+ layout.topSpace = 49
+ layout.bottomSpace = 27
+ layout.iconWidth = 112
+ layout.iconHeight = 88
+ layout.bottomIconSpace = 35
+ return layout
+ case .star:
+ var layout = SPAlertLayout()
+ layout.topSpace = 49
+ layout.bottomSpace = 31
+ layout.iconWidth = 112
+ layout.iconHeight = 92
+ layout.bottomIconSpace = 35
+ return layout
case .add:
var layout = SPAlertLayout()
layout.topSpace = 63
@@ -124,6 +146,10 @@ public enum SPAlertPreset {
return .success
case .add:
return .success
+ case .star:
+ return .success
+ case .moon:
+ return .success
case .error:
return .error
}
diff --git a/Source/SPAlert/Views/Icons/SPAlertIconDocView.swift b/Source/SPAlert/Views/Icons/SPAlertIconDocView.swift
index dd54a94..b60ef67 100644
--- a/Source/SPAlert/Views/Icons/SPAlertIconDocView.swift
+++ b/Source/SPAlert/Views/Icons/SPAlertIconDocView.swift
@@ -40,14 +40,11 @@ public class SPAlertIconDocView: UIView {
class DocDraw: NSObject {
@objc dynamic public class func draw(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 70, height: 87), resizing: ResizingBehavior = .aspectFit, fillColor: UIColor = UIColor(red: 0.349, green: 0.345, blue: 0.353, alpha: 1.000)) {
-
let context = UIGraphicsGetCurrentContext()!
-
context.saveGState()
let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 70, height: 87), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 70, y: resizedFrame.height / 87)
-
let bezierPath = UIBezierPath()
bezierPath.move(to: CGPoint(x: 13.73, y: 86.65))
bezierPath.addLine(to: CGPoint(x: 55.38, y: 86.65))
diff --git a/Source/SPAlert/Views/Icons/SPAlertIconDoneView.swift b/Source/SPAlert/Views/Icons/SPAlertIconDoneView.swift
index cbc6916..39e5df6 100644
--- a/Source/SPAlert/Views/Icons/SPAlertIconDoneView.swift
+++ b/Source/SPAlert/Views/Icons/SPAlertIconDoneView.swift
@@ -24,7 +24,6 @@ import UIKit
public class SPAlertIconDoneView: UIView, SPAlertIconAnimatable {
public func animate() {
-
let length = frame.width
let animatablePath = UIBezierPath()
animatablePath.move(to: CGPoint(x: length * 0.196, y: length * 0.527))
diff --git a/Source/SPAlert/Views/Icons/SPAlertIconHeartView.swift b/Source/SPAlert/Views/Icons/SPAlertIconHeartView.swift
index 33f8965..760b1c7 100644
--- a/Source/SPAlert/Views/Icons/SPAlertIconHeartView.swift
+++ b/Source/SPAlert/Views/Icons/SPAlertIconHeartView.swift
@@ -45,7 +45,6 @@ public class SPAlertIconHeartView: UIView {
let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 510, height: 470), target: targetFrame)
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
context.scaleBy(x: resizedFrame.width / 510, y: resizedFrame.height / 470)
-
let bezierPath = UIBezierPath()
bezierPath.move(to: CGPoint(x: 255, y: 469.6))
bezierPath.addLine(to: CGPoint(x: 219.3, y: 433.9))
diff --git a/Source/SPAlert/Views/Icons/SPAlertIconMoonView.swift b/Source/SPAlert/Views/Icons/SPAlertIconMoonView.swift
new file mode 100644
index 0000000..4e93cd0
--- /dev/null
+++ b/Source/SPAlert/Views/Icons/SPAlertIconMoonView.swift
@@ -0,0 +1,110 @@
+// The MIT License (MIT)
+// Copyright © 2019 Ivan Vorobei (ivanvorobei@icloud.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+import UIKit
+
+public class SPAlertIconMoonView: UIView {
+
+ init() {
+ super.init(frame: .zero)
+ self.backgroundColor = .clear
+ }
+
+ required init?(coder aDecoder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ public override func draw(_ rect: CGRect) {
+ super.draw(rect)
+ MoonDraw.draw(frame: rect, resizing: .aspectFit, fillColor: self.tintColor)
+ }
+
+ class MoonDraw: NSObject {
+
+ @objc dynamic public class func draw(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 53, height: 52), resizing: ResizingBehavior = .aspectFit, fillColor: UIColor = UIColor(red: 0.349, green: 0.345, blue: 0.353, alpha: 1.000)) {
+ let context = UIGraphicsGetCurrentContext()!
+ context.saveGState()
+ let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 53, height: 52), target: targetFrame)
+ context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
+ context.scaleBy(x: resizedFrame.width / 53, y: resizedFrame.height / 52)
+ let bezierPath = UIBezierPath()
+ bezierPath.move(to: CGPoint(x: 40.82, y: 34.76))
+ bezierPath.addCurve(to: CGPoint(x: 48.45, y: 33.58), controlPoint1: CGPoint(x: 43.67, y: 34.76), controlPoint2: CGPoint(x: 46.55, y: 34.16))
+ bezierPath.addLine(to: CGPoint(x: 48.74, y: 33.49))
+ bezierPath.addCurve(to: CGPoint(x: 49.79, y: 33.27), controlPoint1: CGPoint(x: 49.2, y: 33.34), controlPoint2: CGPoint(x: 49.47, y: 33.27))
+ bezierPath.addCurve(to: CGPoint(x: 51.23, y: 34.78), controlPoint1: CGPoint(x: 50.47, y: 33.27), controlPoint2: CGPoint(x: 51.23, y: 33.88))
+ bezierPath.addLine(to: CGPoint(x: 51.22, y: 34.95))
+ bezierPath.addCurve(to: CGPoint(x: 50.96, y: 36.15), controlPoint1: CGPoint(x: 51.2, y: 35.24), controlPoint2: CGPoint(x: 51.14, y: 35.7))
+ bezierPath.addCurve(to: CGPoint(x: 28.28, y: 50.5), controlPoint1: CGPoint(x: 47.93, y: 44.12), controlPoint2: CGPoint(x: 38.81, y: 50.5))
+ bezierPath.addCurve(to: CGPoint(x: 3, y: 25.86), controlPoint1: CGPoint(x: 13.95, y: 50.5), controlPoint2: CGPoint(x: 3, y: 40.23))
+ bezierPath.addCurve(to: CGPoint(x: 18.11, y: 2.27), controlPoint1: CGPoint(x: 3, y: 15.62), controlPoint2: CGPoint(x: 9.06, y: 5.89))
+ bezierPath.addCurve(to: CGPoint(x: 19.5, y: 2), controlPoint1: CGPoint(x: 18.65, y: 2.07), controlPoint2: CGPoint(x: 19.23, y: 2))
+ bezierPath.addCurve(to: CGPoint(x: 20.94, y: 3.39), controlPoint1: CGPoint(x: 20.45, y: 2), controlPoint2: CGPoint(x: 20.94, y: 2.73))
+ bezierPath.addCurve(to: CGPoint(x: 20.67, y: 4.54), controlPoint1: CGPoint(x: 20.94, y: 3.64), controlPoint2: CGPoint(x: 20.89, y: 3.98))
+ bezierPath.addCurve(to: CGPoint(x: 19.13, y: 13.22), controlPoint1: CGPoint(x: 19.79, y: 6.57), controlPoint2: CGPoint(x: 19.13, y: 10.48))
+ bezierPath.addCurve(to: CGPoint(x: 40.82, y: 34.76), controlPoint1: CGPoint(x: 19.13, y: 26.47), controlPoint2: CGPoint(x: 27.59, y: 34.76))
+ bezierPath.close()
+ fillColor.setFill()
+ bezierPath.fill()
+ context.restoreGState()
+ }
+
+ @objc(StyleKitNameResizingBehavior)
+ public enum ResizingBehavior: Int {
+
+ case aspectFit
+ case aspectFill
+ case stretch
+ case center
+
+ public func apply(rect: CGRect, target: CGRect) -> CGRect {
+ if rect == target || target == CGRect.zero {
+ return rect
+ }
+
+ var scales = CGSize.zero
+ scales.width = abs(target.width / rect.width)
+ scales.height = abs(target.height / rect.height)
+
+ switch self {
+ case .aspectFit:
+ scales.width = min(scales.width, scales.height)
+ scales.height = scales.width
+ case .aspectFill:
+ scales.width = max(scales.width, scales.height)
+ scales.height = scales.width
+ case .stretch:
+ break
+ case .center:
+ scales.width = 1
+ scales.height = 1
+ }
+
+ var result = rect.standardized
+ result.size.width *= scales.width
+ result.size.height *= scales.height
+ result.origin.x = target.minX + (target.width - result.width) / 2
+ result.origin.y = target.minY + (target.height - result.height) / 2
+ return result
+ }
+ }
+ }
+}
diff --git a/Source/SPAlert/Views/Icons/SPAlertIconStarView.swift b/Source/SPAlert/Views/Icons/SPAlertIconStarView.swift
new file mode 100644
index 0000000..e13bcb2
--- /dev/null
+++ b/Source/SPAlert/Views/Icons/SPAlertIconStarView.swift
@@ -0,0 +1,116 @@
+// The MIT License (MIT)
+// Copyright © 2019 Ivan Vorobei (ivanvorobei@icloud.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+import UIKit
+
+public class SPAlertIconStarView: UIView {
+
+ init() {
+ super.init(frame: .zero)
+ self.backgroundColor = .clear
+ }
+
+ required init?(coder aDecoder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ public override func draw(_ rect: CGRect) {
+ super.draw(rect)
+ StarDraw.draw(frame: rect, resizing: .aspectFit, fillColor: self.tintColor)
+ }
+
+ class StarDraw: NSObject {
+
+ @objc dynamic public class func draw(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 65, height: 65), resizing: ResizingBehavior = .aspectFit, fillColor: UIColor = UIColor(red: 0.349, green: 0.345, blue: 0.353, alpha: 1.000)) {
+ let context = UIGraphicsGetCurrentContext()!
+ context.saveGState()
+ let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 65, height: 65), target: targetFrame)
+ context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
+ context.scaleBy(x: resizedFrame.width / 65, y: resizedFrame.height / 65)
+ let bezierPath = UIBezierPath()
+ bezierPath.move(to: CGPoint(x: 12.85, y: 61.49))
+ bezierPath.addCurve(to: CGPoint(x: 12.06, y: 57.48), controlPoint1: CGPoint(x: 11.76, y: 60.67), controlPoint2: CGPoint(x: 11.48, y: 59.34))
+ bezierPath.addLine(to: CGPoint(x: 17.96, y: 39.89))
+ bezierPath.addLine(to: CGPoint(x: 3.12, y: 29.24))
+ bezierPath.addCurve(to: CGPoint(x: 1.14, y: 25.35), controlPoint1: CGPoint(x: 1.39, y: 28.02), controlPoint2: CGPoint(x: 0.67, y: 26.71))
+ bezierPath.addCurve(to: CGPoint(x: 5.03, y: 23.35), controlPoint1: CGPoint(x: 1.59, y: 23.99), controlPoint2: CGPoint(x: 2.89, y: 23.32))
+ bezierPath.addLine(to: CGPoint(x: 23.24, y: 23.49))
+ bezierPath.addLine(to: CGPoint(x: 28.77, y: 6.09))
+ bezierPath.addCurve(to: CGPoint(x: 31.86, y: 3), controlPoint1: CGPoint(x: 29.44, y: 4.06), controlPoint2: CGPoint(x: 30.44, y: 3))
+ bezierPath.addCurve(to: CGPoint(x: 34.97, y: 6.09), controlPoint1: CGPoint(x: 33.31, y: 3), controlPoint2: CGPoint(x: 34.31, y: 4.06))
+ bezierPath.addLine(to: CGPoint(x: 40.51, y: 23.49))
+ bezierPath.addLine(to: CGPoint(x: 58.71, y: 23.35))
+ bezierPath.addCurve(to: CGPoint(x: 62.61, y: 25.35), controlPoint1: CGPoint(x: 60.85, y: 23.32), controlPoint2: CGPoint(x: 62.16, y: 23.99))
+ bezierPath.addCurve(to: CGPoint(x: 60.63, y: 29.24), controlPoint1: CGPoint(x: 63.05, y: 26.71), controlPoint2: CGPoint(x: 62.36, y: 28.02))
+ bezierPath.addLine(to: CGPoint(x: 45.79, y: 39.89))
+ bezierPath.addLine(to: CGPoint(x: 51.6, y: 57.21))
+ bezierPath.addCurve(to: CGPoint(x: 50.9, y: 61.49), controlPoint1: CGPoint(x: 52.29, y: 59.21), controlPoint2: CGPoint(x: 52.04, y: 60.63))
+ bezierPath.addCurve(to: CGPoint(x: 46.59, y: 60.82), controlPoint1: CGPoint(x: 49.73, y: 62.38), controlPoint2: CGPoint(x: 48.32, y: 62.07))
+ bezierPath.addLine(to: CGPoint(x: 31.86, y: 50.01))
+ bezierPath.addLine(to: CGPoint(x: 17.15, y: 60.82))
+ bezierPath.addCurve(to: CGPoint(x: 12.85, y: 61.49), controlPoint1: CGPoint(x: 15.43, y: 62.07), controlPoint2: CGPoint(x: 13.98, y: 62.38))
+ bezierPath.close()
+ fillColor.setFill()
+ bezierPath.fill()
+ context.restoreGState()
+ }
+
+ @objc(StyleKitNameResizingBehavior)
+ public enum ResizingBehavior: Int {
+
+ case aspectFit
+ case aspectFill
+ case stretch
+ case center
+
+ public func apply(rect: CGRect, target: CGRect) -> CGRect {
+ if rect == target || target == CGRect.zero {
+ return rect
+ }
+
+ var scales = CGSize.zero
+ scales.width = abs(target.width / rect.width)
+ scales.height = abs(target.height / rect.height)
+
+ switch self {
+ case .aspectFit:
+ scales.width = min(scales.width, scales.height)
+ scales.height = scales.width
+ case .aspectFill:
+ scales.width = max(scales.width, scales.height)
+ scales.height = scales.width
+ case .stretch:
+ break
+ case .center:
+ scales.width = 1
+ scales.height = 1
+ }
+
+ var result = rect.standardized
+ result.size.width *= scales.width
+ result.size.height *= scales.height
+ result.origin.x = target.minX + (target.width - result.width) / 2
+ result.origin.y = target.minY + (target.height - result.height) / 2
+ return result
+ }
+ }
+ }
+}
diff --git a/Source/SPAlert/Views/SPAlertView.swift b/Source/SPAlert/Views/SPAlertView.swift
index b73f92e..dcf7640 100644
--- a/Source/SPAlert/Views/SPAlertView.swift
+++ b/Source/SPAlert/Views/SPAlertView.swift
@@ -72,6 +72,8 @@ open class SPAlertView: UIView {
*/
public var keyWindow: UIView = (UIApplication.shared.keyWindow ?? UIWindow())
+ // MARK: Init
+
public init(title: String, message: String?, preset: SPAlertPreset) {
super.init(frame: CGRect.zero)
iconView = preset.iconView
@@ -175,7 +177,7 @@ open class SPAlertView: UIView {
subtitleLabel?.textColor = color
}
- // MARK: - Public
+ // MARK: Public
/**
Use this method for present controller. No need pass any controller, alert appear on `keyWindow`.
@@ -213,7 +215,7 @@ open class SPAlertView: UIView {
})
}
- // MARK: - Layout
+ // MARK: Layout
open override func layoutSubviews() {
super.layoutSubviews()