From d8e1417e88ac61c1061dfabc71cf98569031d71f Mon Sep 17 00:00:00 2001 From: Aliona Date: Thu, 11 Jan 2018 19:55:01 +0300 Subject: [PATCH 1/8] Add table header bg --- LeadKit.xcodeproj/project.pbxproj | 12 ++++++ .../UITableView/UITableView+Extensions.swift | 38 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Sources/Extensions/UITableView/UITableView+Extensions.swift diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index 2432f93a..ee6b7438 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 2D6A0E6105F4A9BF22BF4BB1 /* Pods_LeadKit_iOS_ExtensionsTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C88ED8C9373F85C06697849 /* Pods_LeadKit_iOS_ExtensionsTests.framework */; }; 2D96F18874B9519F5AD74003 /* Pods_LeadKit_LeadKit_tvOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0F8D0002B21A4F31981F1ED /* Pods_LeadKit_LeadKit_tvOS.framework */; }; 3614FEACB9E8313C87F7C393 /* Pods_LeadKit_tvOSTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DB1CCAB1EAAACD3AC42C795 /* Pods_LeadKit_tvOSTests.framework */; }; + 36DAAF512007CC920090BE0D /* UITableView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36DAAF502007CC920090BE0D /* UITableView+Extensions.swift */; }; 40F118471F8FEF97004AADAF /* AppearanceConfigurable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F118461F8FEF97004AADAF /* AppearanceConfigurable.swift */; }; 40F118491F8FF223004AADAF /* TableRow+AppearanceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F118481F8FF223004AADAF /* TableRow+AppearanceExtension.swift */; }; 67051ADB1EBC7C36008EADC0 /* SpinnerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67051ADA1EBC7C36008EADC0 /* SpinnerView.swift */; }; @@ -404,6 +405,7 @@ 1DA955AE397186D4042066E0 /* Pods-LeadKit-LeadKit iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LeadKit-LeadKit iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-LeadKit-LeadKit iOS/Pods-LeadKit-LeadKit iOS.debug.xcconfig"; sourceTree = ""; }; 287AC0683207753A363152CB /* Pods_LeadKit_watchOSTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_watchOSTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2BD6FE790236CFF8D2CD505E /* Pods-LeadKit-LeadKit iOS Extensions.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LeadKit-LeadKit iOS Extensions.release.xcconfig"; path = "Pods/Target Support Files/Pods-LeadKit-LeadKit iOS Extensions/Pods-LeadKit-LeadKit iOS Extensions.release.xcconfig"; sourceTree = ""; }; + 36DAAF502007CC920090BE0D /* UITableView+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+Extensions.swift"; sourceTree = ""; }; 381DF859FC4E26D499123014 /* Pods-LeadKit iOS ExtensionsTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LeadKit iOS ExtensionsTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-LeadKit iOS ExtensionsTests/Pods-LeadKit iOS ExtensionsTests.release.xcconfig"; sourceTree = ""; }; 3C88ED8C9373F85C06697849 /* Pods_LeadKit_iOS_ExtensionsTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LeadKit_iOS_ExtensionsTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 40F118461F8FEF97004AADAF /* AppearanceConfigurable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceConfigurable.swift; sourceTree = ""; }; @@ -612,6 +614,14 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 36DAAF4F2007CC330090BE0D /* UITableView */ = { + isa = PBXGroup; + children = ( + 36DAAF502007CC920090BE0D /* UITableView+Extensions.swift */, + ); + path = UITableView; + sourceTree = ""; + }; 671461C41EB3396E00EAB194 /* Classes */ = { isa = PBXGroup; children = ( @@ -714,6 +724,7 @@ 679C77D51F98F7A60094BE10 /* UIAlertController */, 671462081EB3396E00EAB194 /* UIColor */, 6714620C1EB3396E00EAB194 /* UIImage */, + 36DAAF4F2007CC330090BE0D /* UITableView */, 671462111EB3396E00EAB194 /* UIView */, 671462171EB3396E00EAB194 /* UIViewController */, 6714621B1EB3396E00EAB194 /* UIWindow */, @@ -1955,6 +1966,7 @@ 67A1FF8F1EBCA09B00D6C89F /* UIImage+Spinner.swift in Sources */, 671462901EB3396E00EAB194 /* CGImage+Crop.swift in Sources */, 671462FC1EB3396E00EAB194 /* UIView+XibNameProtocol.swift in Sources */, + 36DAAF512007CC920090BE0D /* UITableView+Extensions.swift in Sources */, 671463841EB3396E00EAB194 /* ResizeDrawingOperation.swift in Sources */, 6771DFD81EE99EBA002DCDAE /* DateFormattingService.swift in Sources */, 671462D01EB3396E00EAB194 /* UIScrollView+Support.swift in Sources */, diff --git a/Sources/Extensions/UITableView/UITableView+Extensions.swift b/Sources/Extensions/UITableView/UITableView+Extensions.swift new file mode 100644 index 00000000..e57ae098 --- /dev/null +++ b/Sources/Extensions/UITableView/UITableView+Extensions.swift @@ -0,0 +1,38 @@ +// +// Copyright (c) 2017 Touch Instinct +// +// 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 + +extension UITableView { + + /// Adds colored background to the top of the tableview. + /// Use when you need a colored bounce area with a color + /// different from tableview background + func addHeaderBackground(with color: UIColor) { + let backgroundFrame = CGRect(x: frame.origin.x, y: -bounds.height, + width: UIScreen.main.bounds.width, + height: bounds.height) + let backGroundview = UIView(frame: backgroundFrame) + backGroundview.backgroundColor = color + addSubview(backGroundview) + } +} From 0a95f4ae31d161f311c5d1b31a6b73cb424c98e5 Mon Sep 17 00:00:00 2001 From: Aliona Date: Fri, 12 Jan 2018 18:33:51 +0300 Subject: [PATCH 2/8] Add public --- Sources/Extensions/UITableView/UITableView+Extensions.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Extensions/UITableView/UITableView+Extensions.swift b/Sources/Extensions/UITableView/UITableView+Extensions.swift index e57ae098..d2f3fab1 100644 --- a/Sources/Extensions/UITableView/UITableView+Extensions.swift +++ b/Sources/Extensions/UITableView/UITableView+Extensions.swift @@ -22,7 +22,7 @@ import UIKit -extension UITableView { +public extension UITableView { /// Adds colored background to the top of the tableview. /// Use when you need a colored bounce area with a color From 164380196d26d6353169b64861ba5c4fb1cb681e Mon Sep 17 00:00:00 2001 From: Aliona Date: Fri, 12 Jan 2018 19:02:22 +0300 Subject: [PATCH 3/8] Update version --- CHANGELOG.md | 4 ++++ LeadKit.podspec | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78ee81b5..b6bdfced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 0.6.7 + +- **Add**: UITableView extension to add colored background for tableview bounce area. + ### 0.6.6 - **Add**: Ability to map primitive response types (`String`, `Int`, `[String]`, etc.). diff --git a/LeadKit.podspec b/LeadKit.podspec index 0b5caf6b..aec1301d 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "LeadKit" - s.version = "0.6.6" + s.version = "0.6.7" s.summary = "iOS framework with a bunch of tools for rapid development" s.homepage = "https://github.com/TouchInstinct/LeadKit" s.license = "Apache License, Version 2.0" From 287f44ffc2d0b8243a03a288d89d499dc868e10b Mon Sep 17 00:00:00 2001 From: Aliona Date: Mon, 15 Jan 2018 14:11:50 +0300 Subject: [PATCH 4/8] Edit issues for pull request --- .../UITableView/UITableView+Extensions.swift | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Sources/Extensions/UITableView/UITableView+Extensions.swift b/Sources/Extensions/UITableView/UITableView+Extensions.swift index d2f3fab1..6c6cf7f4 100644 --- a/Sources/Extensions/UITableView/UITableView+Extensions.swift +++ b/Sources/Extensions/UITableView/UITableView+Extensions.swift @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Touch Instinct +// Copyright (c) 2018 Touch Instinct // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -25,14 +25,16 @@ import UIKit public extension UITableView { /// Adds colored background to the top of the tableview. - /// Use when you need a colored bounce area with a color - /// different from tableview background + /// + /// - Parameters: + /// - color: background color func addHeaderBackground(with color: UIColor) { - let backgroundFrame = CGRect(x: frame.origin.x, y: -bounds.height, + let backgroundFrame = CGRect(x: frame.origin.x, + y: -bounds.height, width: UIScreen.main.bounds.width, height: bounds.height) - let backGroundview = UIView(frame: backgroundFrame) - backGroundview.backgroundColor = color - addSubview(backGroundview) + let backgroundView = UIView(frame: backgroundFrame) + backgroundView.backgroundColor = color + addSubview(backgroundView) } } From fa5aba357e4a4f1587d6aac230d1c8e56a59ba71 Mon Sep 17 00:00:00 2001 From: Aliona Date: Mon, 15 Jan 2018 16:38:41 +0300 Subject: [PATCH 5/8] Add constraints --- .../UITableView/UITableView+Extensions.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Sources/Extensions/UITableView/UITableView+Extensions.swift b/Sources/Extensions/UITableView/UITableView+Extensions.swift index 6c6cf7f4..c6440a8a 100644 --- a/Sources/Extensions/UITableView/UITableView+Extensions.swift +++ b/Sources/Extensions/UITableView/UITableView+Extensions.swift @@ -27,14 +27,15 @@ public extension UITableView { /// Adds colored background to the top of the tableview. /// /// - Parameters: - /// - color: background color + /// - color: header background color func addHeaderBackground(with color: UIColor) { - let backgroundFrame = CGRect(x: frame.origin.x, - y: -bounds.height, - width: UIScreen.main.bounds.width, - height: bounds.height) - let backgroundView = UIView(frame: backgroundFrame) + let backgroundView = UIView() backgroundView.backgroundColor = color addSubview(backgroundView) + backgroundView.translatesAutoresizingMaskIntoConstraints = false + backgroundView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true + backgroundView.bottomAnchor.constraint(equalTo: topAnchor).isActive = true + backgroundView.widthAnchor.constraint(equalTo: widthAnchor).isActive = true + backgroundView.heightAnchor.constraint(equalTo: heightAnchor).isActive = true } } From ea1cf7b8644238c364a454190b76cfd0b5d7bc20 Mon Sep 17 00:00:00 2001 From: Aliona Date: Mon, 15 Jan 2018 17:59:45 +0300 Subject: [PATCH 6/8] Changes for pull --- LeadKit.xcodeproj/project.pbxproj | 2 ++ .../Extensions/UITableView/UITableView+Extensions.swift | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/LeadKit.xcodeproj/project.pbxproj b/LeadKit.xcodeproj/project.pbxproj index ee6b7438..32f3ca83 100644 --- a/LeadKit.xcodeproj/project.pbxproj +++ b/LeadKit.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 2D6A0E6105F4A9BF22BF4BB1 /* Pods_LeadKit_iOS_ExtensionsTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C88ED8C9373F85C06697849 /* Pods_LeadKit_iOS_ExtensionsTests.framework */; }; 2D96F18874B9519F5AD74003 /* Pods_LeadKit_LeadKit_tvOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0F8D0002B21A4F31981F1ED /* Pods_LeadKit_LeadKit_tvOS.framework */; }; 3614FEACB9E8313C87F7C393 /* Pods_LeadKit_tvOSTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DB1CCAB1EAAACD3AC42C795 /* Pods_LeadKit_tvOSTests.framework */; }; + 36977763200CF12100ED9C6E /* UITableView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36DAAF502007CC920090BE0D /* UITableView+Extensions.swift */; }; 36DAAF512007CC920090BE0D /* UITableView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36DAAF502007CC920090BE0D /* UITableView+Extensions.swift */; }; 40F118471F8FEF97004AADAF /* AppearanceConfigurable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F118461F8FEF97004AADAF /* AppearanceConfigurable.swift */; }; 40F118491F8FF223004AADAF /* TableRow+AppearanceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F118481F8FF223004AADAF /* TableRow+AppearanceExtension.swift */; }; @@ -2199,6 +2200,7 @@ 67A1FF911EBCA09B00D6C89F /* UIImage+Spinner.swift in Sources */, 6714624B1EB3396E00EAB194 /* FixedPageCursor.swift in Sources */, 671462CB1EB3396E00EAB194 /* String+Localization.swift in Sources */, + 36977763200CF12100ED9C6E /* UITableView+Extensions.swift in Sources */, 671462BB1EB3396E00EAB194 /* Sequence+ConcurrentMap.swift in Sources */, 671463771EB3396E00EAB194 /* BorderDrawingOperation.swift in Sources */, 6714633F1EB3396E00EAB194 /* LoadingIndicator.swift in Sources */, diff --git a/Sources/Extensions/UITableView/UITableView+Extensions.swift b/Sources/Extensions/UITableView/UITableView+Extensions.swift index c6440a8a..4eac0278 100644 --- a/Sources/Extensions/UITableView/UITableView+Extensions.swift +++ b/Sources/Extensions/UITableView/UITableView+Extensions.swift @@ -33,9 +33,9 @@ public extension UITableView { backgroundView.backgroundColor = color addSubview(backgroundView) backgroundView.translatesAutoresizingMaskIntoConstraints = false - backgroundView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true - backgroundView.bottomAnchor.constraint(equalTo: topAnchor).isActive = true - backgroundView.widthAnchor.constraint(equalTo: widthAnchor).isActive = true - backgroundView.heightAnchor.constraint(equalTo: heightAnchor).isActive = true + NSLayoutConstraint.activate([ backgroundView.leadingAnchor.constraint(equalTo: leadingAnchor), + backgroundView.bottomAnchor.constraint(equalTo: topAnchor), + backgroundView.widthAnchor.constraint(equalTo: widthAnchor), + backgroundView.heightAnchor.constraint(equalTo: heightAnchor)]) } } From 451bbccc748a62aca5cde61446a052889f979d79 Mon Sep 17 00:00:00 2001 From: Aliona Date: Mon, 15 Jan 2018 18:01:36 +0300 Subject: [PATCH 7/8] Fix spacing --- .../Extensions/UITableView/UITableView+Extensions.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Extensions/UITableView/UITableView+Extensions.swift b/Sources/Extensions/UITableView/UITableView+Extensions.swift index 4eac0278..d6fbdced 100644 --- a/Sources/Extensions/UITableView/UITableView+Extensions.swift +++ b/Sources/Extensions/UITableView/UITableView+Extensions.swift @@ -33,9 +33,9 @@ public extension UITableView { backgroundView.backgroundColor = color addSubview(backgroundView) backgroundView.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([ backgroundView.leadingAnchor.constraint(equalTo: leadingAnchor), - backgroundView.bottomAnchor.constraint(equalTo: topAnchor), - backgroundView.widthAnchor.constraint(equalTo: widthAnchor), - backgroundView.heightAnchor.constraint(equalTo: heightAnchor)]) + NSLayoutConstraint.activate([backgroundView.leadingAnchor.constraint(equalTo: leadingAnchor), + backgroundView.bottomAnchor.constraint(equalTo: topAnchor), + backgroundView.widthAnchor.constraint(equalTo: widthAnchor), + backgroundView.heightAnchor.constraint(equalTo: heightAnchor)]) } } From 08f21469e18539a8594896a2daa5812202c881b0 Mon Sep 17 00:00:00 2001 From: Aliona Date: Mon, 15 Jan 2018 18:38:43 +0300 Subject: [PATCH 8/8] Update podspec --- LeadKit.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/LeadKit.podspec b/LeadKit.podspec index aec1301d..59f27cf7 100644 --- a/LeadKit.podspec +++ b/LeadKit.podspec @@ -59,6 +59,7 @@ Pod::Spec.new do |s| "Sources/Extensions/UICollectionView/*", "Sources/Extensions/UIDevice/*", "Sources/Extensions/UIImage/*", + "Sources/Extensions/UITableView/*", "Sources/Extensions/UIView/*", "Sources/Extensions/UIViewController/*", "Sources/Extensions/UIWindow/*",