diff --git a/Example/EmptyDataDemoTableViewController.swift b/Example/EmptyDataDemoTableViewController.swift index 56009a7..141940e 100644 --- a/Example/EmptyDataDemoTableViewController.swift +++ b/Example/EmptyDataDemoTableViewController.swift @@ -116,6 +116,10 @@ class EmptyDataDemoTableViewController: UITableViewController, TBEmptyDataSetDat return 0 } + func verticalSpacesForEmptyDataSet(scrollView: UIScrollView!) -> [CGFloat] { + return [25, 8] + } + func customViewForEmptyDataSet(scrollView: UIScrollView!) -> UIView? { if isLoading { let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .Gray) diff --git a/Example/Info.plist b/Example/Info.plist index a03da31..41aac54 100644 --- a/Example/Info.plist +++ b/Example/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.5 + 1.6 CFBundleSignature ???? CFBundleVersion - 6 + 7 LSRequiresIPhoneOS UILaunchStoryboardName diff --git a/README.md b/README.md index 22ba5b9..0cd3700 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,8 @@ func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat { // return the vertical offset for EmptyDataSet, default is 0 } -func verticalSpaceForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat { - // return the vertical space for EmptyDataSet, default is 12 +func verticalSpacesForEmptyDataSet(scrollView: UIScrollView!) -> [CGFloat] { + // return the vertical spaces from top to bottom for EmptyDataSet, default is [12, 12] } func customViewForEmptyDataSet(scrollView: UIScrollView!) -> UIView? { diff --git a/TBEmptyDataSet.podspec b/TBEmptyDataSet.podspec index fbe79cb..39c380c 100644 --- a/TBEmptyDataSet.podspec +++ b/TBEmptyDataSet.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "TBEmptyDataSet" - s.version = "1.5" + s.version = "1.6" s.summary = "An extension of UITableView/UICollectionView's super class, it will display a placeholder when the data is empty." s.homepage = "https://github.com/teambition/TBEmptyDataSet" diff --git a/TBEmptyDataSet/EmptyDataView.swift b/TBEmptyDataSet/EmptyDataView.swift index f2dc1fb..c9b395a 100644 --- a/TBEmptyDataSet/EmptyDataView.swift +++ b/TBEmptyDataSet/EmptyDataView.swift @@ -77,7 +77,7 @@ class EmptyDataView: UIView { } var verticalOffset: CGFloat! - var verticalSpace: CGFloat! + var verticalSpaces: [CGFloat]! // MARK: - Helper private func removeAllConstraints() { @@ -172,7 +172,8 @@ class EmptyDataView: UIView { for (index, viewString) in viewStrings.enumerate() { verticalFormat += "[\(viewString)]" if index != viewStrings.count - 1 { - verticalFormat += "-\(verticalSpace)-" + let verticalSpace = index < verticalSpaces.count ? verticalSpaces[index] : DefaultValues.verticalSpace + verticalFormat += "-(\(verticalSpace))-" } } diff --git a/TBEmptyDataSet/ProtocolExtensions.swift b/TBEmptyDataSet/ProtocolExtensions.swift index 7a31f76..523524f 100644 --- a/TBEmptyDataSet/ProtocolExtensions.swift +++ b/TBEmptyDataSet/ProtocolExtensions.swift @@ -33,8 +33,8 @@ public extension TBEmptyDataSetDataSource { return DefaultValues.verticalOffset } - func verticalSpaceForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat { - return DefaultValues.verticalSpace + func verticalSpacesForEmptyDataSet(scrollView: UIScrollView!) -> [CGFloat] { + return [DefaultValues.verticalSpace, DefaultValues.verticalSpace] } func customViewForEmptyDataSet(scrollView: UIScrollView!) -> UIView? { diff --git a/TBEmptyDataSet/Supporting Files/Info.plist b/TBEmptyDataSet/Supporting Files/Info.plist index 033da14..6c0ca92 100644 --- a/TBEmptyDataSet/Supporting Files/Info.plist +++ b/TBEmptyDataSet/Supporting Files/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.5 + 1.6 CFBundleSignature ???? CFBundleVersion diff --git a/TBEmptyDataSet/TBEmptyDataSet.swift b/TBEmptyDataSet/TBEmptyDataSet.swift index 9d1fab3..9628a8f 100644 --- a/TBEmptyDataSet/TBEmptyDataSet.swift +++ b/TBEmptyDataSet/TBEmptyDataSet.swift @@ -17,7 +17,7 @@ public protocol TBEmptyDataSetDataSource: NSObjectProtocol { func backgroundColorForEmptyDataSet(scrollView: UIScrollView!) -> UIColor? func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat - func verticalSpaceForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat + func verticalSpacesForEmptyDataSet(scrollView: UIScrollView!) -> [CGFloat] func customViewForEmptyDataSet(scrollView: UIScrollView!) -> UIView? } @@ -124,8 +124,8 @@ extension UIScrollView: UIGestureRecognizerDelegate { return emptyDataSetDataSource?.verticalOffsetForEmptyDataSet(self) ?? DefaultValues.verticalOffset } - private func emptyDataSetVerticalSpace() -> CGFloat { - return emptyDataSetDataSource?.verticalSpaceForEmptyDataSet(self) ?? DefaultValues.verticalSpace + private func emptyDataSetVerticalSpaces() -> [CGFloat] { + return emptyDataSetDataSource?.verticalSpacesForEmptyDataSet(self) ?? [DefaultValues.verticalSpace, DefaultValues.verticalSpace] } private func emptyDataSetCustomView() -> UIView? { @@ -252,7 +252,7 @@ extension UIScrollView: UIGestureRecognizerDelegate { emptyDataView.resetEmptyDataView() emptyDataView!.verticalOffset = emptyDataSetVerticalOffset() - emptyDataView!.verticalSpace = emptyDataSetVerticalSpace() + emptyDataView!.verticalSpaces = emptyDataSetVerticalSpaces() if let customView = emptyDataSetCustomView() { emptyDataView.customView = customView