diff --git a/EasySwiftLayout.podspec b/EasySwiftLayout.podspec index 5b51922..7190fa4 100644 --- a/EasySwiftLayout.podspec +++ b/EasySwiftLayout.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'EasySwiftLayout' - s.version = '1.5.0' + s.version = '1.5.1' s.license = 'MIT' s.summary = 'Lightweight Swift framework for Auto-Layout. Helps you write readable and compact UI code using simple API.' s.homepage = 'https://github.com/denandreychuk/EasySwiftLayout' @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.social_media_url = 'https://www.instagram.com/den.andreychuk' s.source = { :git => 'https://github.com/denandreychuk/EasySwiftLayout.git', :tag => s.version.to_s } - s.source_files = 'Source/*.swift' + s.source_files = 'Sources/*.swift' s.swift_version = '5.0' s.platform = :ios, "9.0" end diff --git a/EasySwiftLayout.xcodeproj/project.pbxproj b/EasySwiftLayout.xcodeproj/project.pbxproj index 23c9307..067d16d 100644 --- a/EasySwiftLayout.xcodeproj/project.pbxproj +++ b/EasySwiftLayout.xcodeproj/project.pbxproj @@ -44,6 +44,7 @@ B7DB42432471A106001FE565 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB42412471A106001FE565 /* Utilities.swift */; }; B7DB424A2471A216001FE565 /* UIStackView+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB42482471A216001FE565 /* UIStackView+Utilities.swift */; }; B7DB424B2471A216001FE565 /* UIView+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB42492471A216001FE565 /* UIView+Utilities.swift */; }; + B7DB424D2471B038001FE565 /* UIView + Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB424C2471B038001FE565 /* UIView + Helpers.swift */; }; B7E52714236EFE0C006760A0 /* Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7E52713236EFE0C006760A0 /* Deprecated.swift */; }; B7FC923523422CAA009947A3 /* UIView + Pin(Superview).swift in Sources */ = {isa = PBXBuildFile; fileRef = B7FC923423422CAA009947A3 /* UIView + Pin(Superview).swift */; }; /* End PBXBuildFile section */ @@ -87,6 +88,7 @@ B7DB42412471A106001FE565 /* Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Utilities.swift; sourceTree = ""; }; B7DB42482471A216001FE565 /* UIStackView+Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIStackView+Utilities.swift"; sourceTree = ""; }; B7DB42492471A216001FE565 /* UIView+Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Utilities.swift"; sourceTree = ""; }; + B7DB424C2471B038001FE565 /* UIView + Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView + Helpers.swift"; sourceTree = ""; }; B7E52713236EFE0C006760A0 /* Deprecated.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Deprecated.swift; sourceTree = ""; }; B7F431AE234A5CF700C7E7C7 /* EasySwiftLayout.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = EasySwiftLayout.framework; path = ../ContentProtectorKit/EasySwiftLayout.framework; sourceTree = ""; }; B7FC923423422CAA009947A3 /* UIView + Pin(Superview).swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView + Pin(Superview).swift"; sourceTree = ""; }; @@ -147,6 +149,7 @@ B74F8CB823784CCD00C67F28 /* Helpers */ = { isa = PBXGroup; children = ( + B7DB424C2471B038001FE565 /* UIView + Helpers.swift */, B74F8CB52378292C00C67F28 /* UIEdgeInsets + Helpers.swift */, ); name = Helpers; @@ -443,6 +446,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + B7DB424D2471B038001FE565 /* UIView + Helpers.swift in Sources */, B7B6608B22FF6AAF006FDD7E /* UIView + Pin.swift in Sources */, B7B6608922FF61EE006FDD7E /* ESLAxis.swift in Sources */, B7735CF9245C62E7007C6DAD /* ESLSizeInsets.swift in Sources */, @@ -671,7 +675,7 @@ CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 0; + CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = F7NGW4S7J5; DYLIB_COMPATIBILITY_VERSION = 1; @@ -699,7 +703,7 @@ CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 0; + CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = F7NGW4S7J5; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/Example-IOS/Sources/Extensions/UIView+Utilities.swift b/Example-IOS/Sources/Extensions/UIView+Utilities.swift index 0961a2a..e673782 100644 --- a/Example-IOS/Sources/Extensions/UIView+Utilities.swift +++ b/Example-IOS/Sources/Extensions/UIView+Utilities.swift @@ -27,12 +27,6 @@ import UIKit extension UIView { - @discardableResult - func add(toSuperview superview: UIView) -> Self { - superview.addSubview(self) - return self - } - func addShadow(ofColor color: UIColor = .black, radius: CGFloat = 3, offset: CGSize = .zero, opacity: Float = 0.5) { layer.shadowColor = color.cgColor layer.shadowOffset = offset diff --git a/Example-IOS/Sources/HomeController.swift b/Example-IOS/Sources/HomeController.swift index 445ff98..eab3e0b 100644 --- a/Example-IOS/Sources/HomeController.swift +++ b/Example-IOS/Sources/HomeController.swift @@ -70,7 +70,7 @@ final class HomeController: UIViewController { $0.text = "Join a community dedicated \nto keeping each other safe" } - private let startButton = configure(RoundedButton(type: .system)) { + private let nextButton = configure(RoundedButton(type: .system)) { $0.tintColor = .white $0.backgroundColor = #colorLiteral(red: 0.8078431373, green: 0.3882352941, blue: 1, alpha: 1) $0.setTitle("Next", for: .normal) @@ -120,9 +120,9 @@ private extension HomeController { .add(toSuperview: view) .pinEdgesToSuperview(excludingEdge: .bottom, withInset: 25, respectingGuide: .safeAreaLayout) - // Start button + // Next button - startButton + nextButton .add(toSuperview: view) .centerInSuperview(axis: .x) .size(CGSize(width: 150, height: 55)) diff --git a/README.md b/README.md index 58eff97..b1bcce7 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ class ViewController: UIViewController { -EasySwiftLayout comes with [project example](https://github.com/denandreychuk/EasySwiftLayout/tree/master/Example-IOS). You can check out how easily you can create screens like this with ESL. +EasySwiftLayout comes with [project example](https://github.com/denandreychuk/EasySwiftLayout/tree/master/Example-IOS). You can check out how easily you can create screens like this with ESL: - Navigate to the project folder and open `EasySwiftLayout.xcodeproj`. - Select scheme `Example-IOS` by pressing `^ + 0` and just run it on any device. @@ -109,6 +109,36 @@ EasySwiftLayout comes with [project example](https://github.com/denandreychuk/Ea ### `UIView` Extenstions: +#### Helpers + +
+add(toSuperview:) + +##### Summary + +Adds the view as a subview of specified superview. + +##### Declaration + +```swift +func add(toSuperview superview: UIView) -> Self +``` + +##### Parameters + +Parameter | Type | Description +---------- | ---- |------------ +superview | `UIView` | The superview to which add subview. + +##### Returns + +`self` with attribute `@discardableResult`. + +##### Declared In +[UIView + Helpers.swift](https://github.com/denandreychuk/EasySwiftLayout/blob/master/Sources/UIView%20%2B%20Helpers.swift) + +
+ #### Size Methods (Constants)
diff --git a/Sources/UIEdgeInsets + Helpers.swift b/Sources/UIEdgeInsets + Helpers.swift index 946a046..e08d738 100644 --- a/Sources/UIEdgeInsets + Helpers.swift +++ b/Sources/UIEdgeInsets + Helpers.swift @@ -1,10 +1,27 @@ // -// UIEdgeInsets + Helpers.swift -// EasySwiftLayout +// UIView + Pin.swift +// https://github.com/denandreychuk/EasySwiftLayout // -// Created by Денис Андрейчук on 10.11.2019. -// Copyright © 2019 Denis Andreychuk. All rights reserved. +// This code is distributed under the terms and conditions of the MIT license. +// Copyright (c) 2019-2020 Denis Andreychuk // +// 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 diff --git a/Sources/UIView + Helpers.swift b/Sources/UIView + Helpers.swift new file mode 100644 index 0000000..a642534 --- /dev/null +++ b/Sources/UIView + Helpers.swift @@ -0,0 +1,41 @@ +// +// UIView + Helpers.swift +// https://github.com/denandreychuk/EasySwiftLayout +// +// This code is distributed under the terms and conditions of the MIT license. +// Copyright (c) 2020 Denis Andreychuk +// +// 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 extension UIView { + + /// Adds the view as a subview of specified superview. + /// + /// - Parameter superview: The superview to which add subview. + /// + /// - Returns: `self` with attribute `@discardableResult`. + /// + @discardableResult + func add(toSuperview superview: UIView) -> Self { + superview.addSubview(self) + return self + } +}