diff --git a/Example/Podfile.lock b/Example/Podfile.lock
index 3c05903..7e79c5a 100644
--- a/Example/Podfile.lock
+++ b/Example/Podfile.lock
@@ -1,16 +1,16 @@
PODS:
- - UIEmptyState (3.1.0)
+ - UIEmptyState (3.1.1)
DEPENDENCIES:
- UIEmptyState (from `../`)
EXTERNAL SOURCES:
UIEmptyState:
- :path: ../
+ :path: "../"
SPEC CHECKSUMS:
- UIEmptyState: 9b501dc90933ce2743949ecbf18c20ffb33a2be9
+ UIEmptyState: 801fb97bc13d0ec75e32ba0a111538683aea69f5
PODFILE CHECKSUM: 2410e5e41e5d4570ddd34538c5ba93d5d35ce08c
-COCOAPODS: 1.3.1
+COCOAPODS: 1.9.1
diff --git a/Example/UIEmptyStateExample.xcodeproj/project.pbxproj b/Example/UIEmptyStateExample.xcodeproj/project.pbxproj
index 0fd53f7..89c8f8a 100644
--- a/Example/UIEmptyStateExample.xcodeproj/project.pbxproj
+++ b/Example/UIEmptyStateExample.xcodeproj/project.pbxproj
@@ -122,7 +122,6 @@
A05AA1BB1E4560E800B851F7 /* Frameworks */,
A05AA1BC1E4560E800B851F7 /* Resources */,
0085D2E6DEBEFB5796183033 /* [CP] Embed Pods Frameworks */,
- 24B3590701ADC38465D2548E /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -146,7 +145,7 @@
A05AA1BD1E4560E800B851F7 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 4FNMZ7SN42;
- LastSwiftMigration = 0900;
+ LastSwiftMigration = 1140;
ProvisioningStyle = Automatic;
};
};
@@ -156,6 +155,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
+ English,
en,
Base,
);
@@ -189,7 +189,7 @@
files = (
);
inputPaths = (
- "${SRCROOT}/Pods/Target Support Files/Pods-UIEmptyStateExample/Pods-UIEmptyStateExample-frameworks.sh",
+ "${PODS_ROOT}/Target Support Files/Pods-UIEmptyStateExample/Pods-UIEmptyStateExample-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/UIEmptyState/UIEmptyState.framework",
);
name = "[CP] Embed Pods Frameworks";
@@ -198,22 +198,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-UIEmptyStateExample/Pods-UIEmptyStateExample-frameworks.sh\"\n";
- showEnvVarsInLog = 0;
- };
- 24B3590701ADC38465D2548E /* [CP] Copy Pods Resources */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- name = "[CP] Copy Pods Resources";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-UIEmptyStateExample/Pods-UIEmptyStateExample-resources.sh\"\n";
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-UIEmptyStateExample/Pods-UIEmptyStateExample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
7D72286EB8A21429E4DC3E74 /* [CP] Check Pods Manifest.lock */ = {
@@ -386,7 +371,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.luispadron.UIEmptyStateExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -401,7 +386,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.luispadron.UIEmptyStateExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
};
name = Release;
};
diff --git a/Example/UIEmptyStateExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/UIEmptyStateExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/Example/UIEmptyStateExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Example/UIEmptyStateExample/AppDelegate.swift b/Example/UIEmptyStateExample/AppDelegate.swift
index e10d861..de7b36d 100644
--- a/Example/UIEmptyStateExample/AppDelegate.swift
+++ b/Example/UIEmptyStateExample/AppDelegate.swift
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
diff --git a/Example/UIEmptyStateExample/EmptyStateTableViewController.swift b/Example/UIEmptyStateExample/EmptyStateTableViewController.swift
index b5de404..0998a5c 100644
--- a/Example/UIEmptyStateExample/EmptyStateTableViewController.swift
+++ b/Example/UIEmptyStateExample/EmptyStateTableViewController.swift
@@ -33,14 +33,14 @@ class EmptyStateTableViewController: UITableViewController, UIEmptyStateDelegate
}
var emptyStateTitle: NSAttributedString {
- let attrs = [NSAttributedStringKey.foregroundColor: UIColor(red: 0.882, green: 0.890, blue: 0.859, alpha: 1.00),
- NSAttributedStringKey.font: UIFont.systemFont(ofSize: 22)]
+ let attrs = [NSAttributedString.Key.foregroundColor: UIColor(red: 0.882, green: 0.890, blue: 0.859, alpha: 1.00),
+ NSAttributedString.Key.font: UIFont.systemFont(ofSize: 22)]
return NSAttributedString(string: "No Pokemon caught!", attributes: attrs)
}
var emptyStateButtonTitle: NSAttributedString? {
- let attrs = [NSAttributedStringKey.foregroundColor: UIColor.white,
- NSAttributedStringKey.font: UIFont.systemFont(ofSize: 16)]
+ let attrs = [NSAttributedString.Key.foregroundColor: UIColor.white,
+ NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)]
return NSAttributedString(string: "Catch'em All", attributes: attrs)
}
@@ -83,7 +83,7 @@ class EmptyStateTableViewController: UITableViewController, UIEmptyStateDelegate
return cell
}
- override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
+ override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row
tableView.beginUpdates()
diff --git a/UIEmptyState.podspec b/UIEmptyState.podspec
index 0a1f6a8..502c8d8 100644
--- a/UIEmptyState.podspec
+++ b/UIEmptyState.podspec
@@ -2,7 +2,7 @@
Pod::Spec.new do |s|
s.name = "UIEmptyState"
- s.version = "3.1.0"
+ s.version = "3.1.1"
s.summary = "An empty state control to give visually appealing context when building iOS applications."
s.description = <<-DESC
Empty state control which gives context with either a message, image, and buttons to the user when ever there is a reason the state is empty.
diff --git a/UIEmptyState.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/UIEmptyState.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/UIEmptyState.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/UIEmptyState/UIEmptyStateDataSource.swift b/UIEmptyState/UIEmptyStateDataSource.swift
index 670e3de..aaf8f2d 100644
--- a/UIEmptyState/UIEmptyStateDataSource.swift
+++ b/UIEmptyState/UIEmptyStateDataSource.swift
@@ -159,6 +159,8 @@ public protocol UIEmptyStateDataSource: class {
*/
func emptyStateViewAnimation(for view: UIView, animationDuration: TimeInterval,
completion: ((Bool) -> Void)?) -> Void
+
+ var emptyStateContainerView: UIView { get }
}
/// Extension for the UIEmptyDataSource which adds a default implementation for any UIViewController Subclass
@@ -260,6 +262,8 @@ extension UIEmptyStateDataSource where Self: UIViewController {
/// Default implementation of `emptyStateViewAnimationDuration`, returns `0.5`
public var emptyStateViewAnimationDuration: TimeInterval { get { return 0.5 } }
+ public var emptyStateContainerView: UIView { return self.view }
+
/// Default implementation of `emptyStateViewAnimation`, implements a simple animation
public func emptyStateViewAnimation(for view: UIView, animationDuration: TimeInterval,
completion: ((Bool) -> Void)?) -> Void {
diff --git a/UIEmptyState/UIEmptyStateView.swift b/UIEmptyState/UIEmptyStateView.swift
index 88db67e..b0239d1 100644
--- a/UIEmptyState/UIEmptyStateView.swift
+++ b/UIEmptyState/UIEmptyStateView.swift
@@ -159,7 +159,7 @@ open class UIEmptyStateView: UIView {
return
}
- detailLabel.attributedText = message
+ detailLabel.attributedText = NSAttributedString(string: message.string)
self.setNeedsUpdateConstraints()
handleAdding(view: detailLabel)
}
@@ -253,7 +253,7 @@ open class UIEmptyStateView: UIView {
contentView.axis = .vertical
contentView.distribution = .equalSpacing
contentView.alignment = .center
- contentView.backgroundColor = UIColor.red
+ contentView.backgroundColor = .clear
contentView.spacing = spacing ?? 0
contentView.translatesAutoresizingMaskIntoConstraints = false
contentView.addArrangedSubview(titleLabel)
@@ -270,7 +270,7 @@ open class UIEmptyStateView: UIView {
private func handleAdding(view: UIView) {
// The order we want is 1. Image View, 2. Title Label, 3. Detail Label, 4. Button
// If already added we can return
- if contentView.subviews.index(of: view) != nil { return }
+ if contentView.subviews.firstIndex(of: view) != nil { return }
// Tags correspond to the views AND the order we want them in
switch view.tag {
diff --git a/UIEmptyState/UIViewController+UIEmptyState.swift b/UIEmptyState/UIViewController+UIEmptyState.swift
index 70347e1..5b14dd6 100644
--- a/UIEmptyState/UIViewController+UIEmptyState.swift
+++ b/UIEmptyState/UIViewController+UIEmptyState.swift
@@ -25,7 +25,7 @@ extension UIViewController {
*/
public weak var emptyStateDataSource: UIEmptyStateDataSource? {
get { return objc_getAssociatedObject(self, &Keys.emptyStateDataSource) as? UIEmptyStateDataSource }
- set { objc_setAssociatedObject(self, &Keys.emptyStateDataSource, newValue, .OBJC_ASSOCIATION_RETAIN) }
+ set { objc_setAssociatedObject(self, &Keys.emptyStateDataSource, newValue, .OBJC_ASSOCIATION_ASSIGN) }
}
/**
@@ -36,7 +36,7 @@ extension UIViewController {
*/
public weak var emptyStateDelegate: UIEmptyStateDelegate? {
get { return objc_getAssociatedObject(self, &Keys.emptyStateDelegate) as? UIEmptyStateDelegate }
- set { objc_setAssociatedObject(self, &Keys.emptyStateDelegate, newValue, .OBJC_ASSOCIATION_RETAIN) }
+ set { objc_setAssociatedObject(self, &Keys.emptyStateDelegate, newValue, .OBJC_ASSOCIATION_ASSIGN) }
}
/**
@@ -137,9 +137,9 @@ extension UIViewController {
//// Private helper which creates view contraints for the UIEmptyStateView.
private func createViewConstraints(for view: UIView, in source: UIEmptyStateDataSource) {
// Set constraints
- var centerX = view.centerXAnchor.constraint(equalTo: self.view.centerXAnchor)
+ var centerX = view.centerXAnchor.constraint(equalTo: source.emptyStateContainerView.centerXAnchor)
centerX.isActive = true
- var centerY = view.centerYAnchor.constraint(equalTo: self.view.centerYAnchor)
+ var centerY = view.centerYAnchor.constraint(equalTo: source.emptyStateContainerView.centerYAnchor)
centerY.isActive = true
// If iOS 11.0 is not available, then adjust the extended layout accordingly using older API
@@ -160,11 +160,11 @@ extension UIViewController {
if source.emptyStateViewAdjustsToFitBars {
// Adjust constraint to fit new big title bars, etc
centerX.isActive = false
- centerX = view.centerXAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.centerXAnchor)
+ centerX = view.centerXAnchor.constraint(equalTo: source.emptyStateContainerView.safeAreaLayoutGuide.centerXAnchor)
centerX.isActive = true
centerY.isActive = false
- centerY = view.centerYAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.centerYAnchor)
+ centerY = view.centerYAnchor.constraint(equalTo: source.emptyStateContainerView.safeAreaLayoutGuide.centerYAnchor)
centerY.isActive = true
}
@@ -216,8 +216,10 @@ extension UIViewController {
// Add to emptyStateView property
emptyView = newView
// Add as a subView, bring it infront of the tableView
- self.view.addSubview(newView)
- self.view.bringSubview(toFront: newView)
+
+ self.emptyStateDataSource?.emptyStateContainerView.addSubview(newView)
+ self.emptyStateDataSource?.emptyStateContainerView.sendSubviewToBack(newView)
+
// Animate now
if source.emptyStateViewCanAnimate {
DispatchQueue.main.async {