├── .DS_Store
├── .gitignore
├── .swiftpm
└── xcode
│ └── package.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── LICENSE
├── Package.swift
├── README.md
├── SimplyLayout.podspec
├── SimplyLayout.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── xcshareddata
│ └── xcschemes
│ └── SimplyLayout.xcscheme
├── Sources
├── SimplyLayout
│ ├── Anchor
│ │ ├── CenterAnchor.swift
│ │ └── EdgeAnchor.swift
│ ├── Core
│ │ ├── AttributedAnchor.swift
│ │ ├── AttributedConstant.swift
│ │ ├── AttributedDimension.swift
│ │ ├── NSLayoutAxisAnchorExtension.swift
│ │ ├── NSLayoutConstraintExtension.swift
│ │ ├── NSLayoutDimensionExtension.swift
│ │ └── SimplyLayout.swift
│ ├── Group
│ │ └── ConstraintGroup.swift
│ ├── Info.plist
│ └── SimplyLayout.h
└── SimplyLayoutDemo
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── ViewController.swift
└── Tests
└── SimplyLayoutTests
└── Test.swift
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aipeople/SimplyLayout/1d4c3ce9698e70bde6662e40b5bb0a4641c57791/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | ## Playgrounds
32 | timeline.xctimeline
33 | playground.xcworkspace
34 |
35 | # Swift Package Manager
36 | #
37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
38 | # Packages/
39 | # Package.pins
40 | .build/
41 |
42 | # CocoaPods
43 | #
44 | # We recommend against adding the Pods directory to your .gitignore. However
45 | # you should judge for yourself, the pros and cons are mentioned at:
46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
47 | #
48 | # Pods/
49 |
50 | # Carthage
51 | #
52 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
53 | # Carthage/Checkouts
54 |
55 | Carthage/Build
56 |
57 | # fastlane
58 | #
59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
60 | # screenshots whenever they are needed.
61 | # For more information about the recommended setup visit:
62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
63 |
64 | fastlane/report.xml
65 | fastlane/Preview.html
66 | fastlane/screenshots
67 | fastlane/test_output
68 | .DS_Store
69 |
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Su Xing-Yu
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version: 5.9
2 | // The swift-tools-version declares the minimum version of Swift required to build this package.
3 |
4 | import PackageDescription
5 |
6 | let package = Package(
7 | name: "SimplyLayout",
8 | products: [
9 | // Products define the executables and libraries a package produces, making them visible to other packages.
10 | .library(
11 | name: "SimplyLayout",
12 | targets: ["SimplyLayout"]),
13 | ],
14 | targets: [
15 | // Targets are the basic building blocks of a package, defining a module or a test suite.
16 | // Targets can depend on other targets in this package and products from dependencies.
17 | .target(
18 | name: "SimplyLayout"),
19 | .testTarget(
20 | name: "SimplyLayoutTests",
21 | dependencies: ["SimplyLayout"]),
22 | ]
23 | )
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SimplyLayout
2 | A swift syntactic sugar for anchor based Auto Layout
3 |
4 | # Installation
5 | ### CocoaPod
6 | ````
7 | # Swift 4 with full functions, including `Core`, `Anchor` and `Group`
8 | pod 'SimplyLayout'
9 |
10 | # Swift 4 with syntactic sugar only
11 | pod 'SimplyLayout/Core'
12 |
13 | # Swift 4 with convenience virtual anchors (CenterAnchor, EdgeAnchor, etc.)
14 | pod 'SimplyLayout/Anchor'
15 |
16 | # Swift 4 with constraint grouping functions
17 | pod 'SimplyLayout/Group'
18 |
19 | # Swift 3
20 | pod 'SimplyLayout', :git => 'https://github.com/aipeople/SimplyLayout.git', :tag => 'swift3-1.0.1'
21 | ````
22 |
23 | # Usage
24 | ### Operator
25 | * `+`, `-` -> Set the constant
26 | * `*` -> Set the multiplier
27 | * `~` -> Set the priority
28 |
29 | Example:
30 | ```` swift
31 | import SimplyLayout
32 |
33 | view.widthAnchor == 100
34 | // view.widthAnchor.constraint(equalToConstant: 100).isActive = true
35 | // view.translatesAutoresizingMaskIntoConstraints = false
36 |
37 | view.heightAnchor == view.superview!.heightAnchor * 0.25 + 40 ~ .defautHigh
38 | // let constraint = view.heightAnchor.constraint(equalTo: view.superview!.heightAnchor, multiplier: 0.25, constant: 40)
39 | // constraint.priority = .defaultHigh
40 | // constraint.isActive = true
41 | // view.translatesAutoresizingMaskIntoConstraints = false
42 | ````
43 |
44 | ### Activation
45 | Constraints will be activated automatically.
46 | You can turn this feature off by setting the `SimplyLayout.config.defaultActivation` to `false`.
47 | For some reasons, you may want to create a constraint with different activation status. `++` and `--` can help you get rid of default configs.
48 |
49 | Example:
50 | ```` swift
51 | SimplyLayout.config.defaultActivation = true
52 |
53 | view.widthAnchor == 100
54 | // view.widthAnchor.constraint(equalToConstant: 100).isActive = true
55 |
56 | view.widthAnchor == --100
57 | // view.widthAnchor.constraint(equalToConstant: 100)
58 |
59 | SimplyLayout.config.defaultActivation = false
60 |
61 | view.heightAnchor == view.superview!.heightAnchor * 0.25
62 | // let constraint = view.heightAnchor.constraint(equalTo: view.superview!.heightAnchor, multiplier: 0.25)
63 |
64 | view.heightAnchor == ++view.superview!.heightAnchor * 0.25
65 | // let constraint = view.heightAnchor.constraint(equalTo: view.superview!.heightAnchor, multiplier: 0.25)
66 | // constraint.isActive = true
67 | ````
68 |
69 | ### Access the constraint
70 | A new created constraint can be accessed easily by using the `=` operator.
71 |
72 | Example:
73 | ```` swift
74 | let constraint = view.heightAnchor == view.superview!.heightAnchor * 0.25
75 | ````
76 |
77 | ### Virtual Anchor
78 | Virtual anchors **are not** real `NSLayoutAnchor`. These anchors just help you create the constraints esily.
79 | * **`CenterAnchor`**
80 | ```` swift
81 | view.centerAnchor == view.superview!.centerAnchor + CGPoint(x: 10, y: 10)
82 | // view.centerXAnchor == view.superview!.centerXAnchor + 10
83 | // view.centerYAnchor == view.superview!.centerYAnchor + 10
84 | ````
85 | * **`EdgeAnchor`**
86 | ```` swift
87 | view.edgeAnchor == view.superview!.edgeAnchor
88 | // view.topAnchor == view.superview!.topAnchor
89 | // view.leadingAnchor == view.superview!.leadingAnchor
90 | // view.bottomAnchor == view.superview!.bottomAnchor
91 | // view.trailingAnchor == view.superview!.trailingAnchor
92 |
93 | view.edgeAnchor == view.superview!.edgeAnchor.insetBy(top: 10, left: 20, bottom: 10, right: 20)
94 | // view.edgeAnchor == view.superview!.edgeAnchor + UIEdgeInsets(top: 10, left: 20, bottom: 10, right: 20)
95 | // -----------------------(equals to)------------------------
96 | // view.topAnchor == view.superview!.topAnchor + 10
97 | // view.leadingAnchor == view.superview!.leadingAnchor + 20
98 | // view.bottomAnchor == view.superview!.bottomAnchor - 10
99 | // view.trailingAnchor == view.superview!.trailingAnchor - 20
100 | ````
101 |
102 | ### Grouping
103 | Grouping functions require `SimplyLayout/Group` submodule. It provides a convenience way to group several constraints together. A group of constraints is represented by an array of NSLayoutConstraint, which can be activated/deactivated together.
104 |
105 | Example:
106 | ```` swift
107 | let boxA = UIView()
108 | let boxB = UIView()
109 |
110 | // `verticalConstraintGroup` is an array with NSLayoutConstraint.
111 | // In the following case, it will contains two constraints.
112 | let verticalConstraintGroup = NSLayoutConstraint.group {
113 | boxA.centerXAnchor == boxA.superview!.centerXAnchor
114 | boxB.centerXAnchor == boxB.superview!.centerXAnchor
115 | }
116 |
117 | // All the constraints created in the block won't be activated
118 | let horizontalConstraintGroup = NSLayoutConstraint.group(activated: false) {
119 | boxA.centerYAnchor == boxA.superview!.centerYAnchor
120 | boxB.centerYAnchor == boxB.superview!.centerYAnchor
121 | }
122 |
123 | // Deactivate all constraints in the group
124 | verticalConstraintGroup.deactivateAll()
125 |
126 | // Activate all constraints in the group
127 | horizontalConstraintGroup.activateAll()
128 | ````
129 |
130 | # Configurations
131 | * `postNotificationWhenConstrantCreate`: A notification named `SimplyLayout.constraintCreatedNotification` will be posted immediately after a constraint has been setup by using the syntax of SimplyLayout. Default value is `false`.
132 |
133 | Constraint related behavior can be set in `SimplyLayout.config`.
134 | * `defaultPriority`:Default value is `.required`
135 | * `defaultActivation`:Default value is `true`
136 |
--------------------------------------------------------------------------------
/SimplyLayout.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod spec lint SimplyLayout.podspec' to ensure this is a
3 | # valid spec and to remove all comments including this before submitting the spec.
4 | #
5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
7 | #
8 |
9 | Pod::Spec.new do |s|
10 |
11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
12 | #
13 | # These will help people to find your library, and whilst it
14 | # can feel like a chore to fill in it's definitely to your advantage. The
15 | # summary should be tweet-length, and the description more in depth.
16 | #
17 |
18 | s.name = "SimplyLayout"
19 | s.version = "1.2.0"
20 | s.summary = "A swift syntactic sugar for anchor based Auto Layout"
21 |
22 | # This description is used to generate tags and improve search results.
23 | # * Think: What does it do? Why did you write it? What is the focus?
24 | # * Try to keep it short, snappy and to the point.
25 | # * Write the description between the DESC delimiters below.
26 | # * Finally, don't worry about the indent, CocoaPods strips it!
27 | s.description = <<-DESC
28 | Create Auto Layout constraints in formula liked coding style.
29 | DESC
30 |
31 | s.homepage = "https://github.com/aipeople/SimplyLayout"
32 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
33 |
34 |
35 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
36 | #
37 | # Licensing your code is important. See http://choosealicense.com for more info.
38 | # CocoaPods will detect a license file if there is a named LICENSE*
39 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
40 | #
41 |
42 | s.license = "MIT"
43 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
44 |
45 |
46 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
47 | #
48 | # Specify the authors of the library, with email addresses. Email addresses
49 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
50 | # accepts just a name if you'd rather not provide an email address.
51 | #
52 | # Specify a social_media_url where others can refer to, for example a twitter
53 | # profile URL.
54 | #
55 |
56 | s.author = { "Su, Hsing-Yu" => "aipeople0513@gmail.com" }
57 | # Or just: s.author = "Su Xing-Yu"
58 | # s.authors = { "Su Xing-Yu" => "email@address.com" }
59 | # s.social_media_url = "http://twitter.com/Su Xing-Yu"
60 |
61 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
62 | #
63 | # If this Pod runs only on iOS or OS X, then specify the platform and
64 | # the deployment target. You can optionally include the target after the platform.
65 | #
66 |
67 | # s.platform = :ios
68 | s.platform = :ios, "9.0"
69 | s.swift_versions = '4.0', '5.0'
70 |
71 | # When using multiple platforms
72 | # s.ios.deployment_target = "5.0"
73 | # s.osx.deployment_target = "10.7"
74 | # s.watchos.deployment_target = "2.0"
75 | # s.tvos.deployment_target = "9.0"
76 |
77 |
78 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
79 | #
80 | # Specify the location from where the source should be retrieved.
81 | # Supports git, hg, bzr, svn and HTTP.
82 | #
83 |
84 | s.source = { :git => "https://github.com/aipeople/SimplyLayout.git", :tag => "1.2.0" }
85 |
86 |
87 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
88 | #
89 | # CocoaPods is smart about how it includes source code. For source files
90 | # giving a folder will include any swift, h, m, mm, c & cpp files.
91 | # For header files it will include any header in the folder.
92 | # Not including the public_header_files will make all headers public.
93 | #
94 |
95 | s.source_files = "Sources/SimplyLayout/{Core, Anchor, Group}/**/*.{swift}"
96 | # s.exclude_files = "Classes/Exclude"
97 |
98 | # s.public_header_files = "Classes/**/*.h"
99 |
100 | s.default_subspecs = 'Core', 'Anchor', 'Group'
101 | s.subspec 'Core' do |sp|
102 | sp.source_files = 'Sources/SimplyLayout/Core/**/*.{swift}', 'Sources/SimplyLayout/SimplyLayout.h'
103 | end
104 |
105 | s.subspec 'Anchor' do |sp|
106 | sp.source_files = 'Sources/SimplyLayout/Anchor/**/*.{swift}'
107 | sp.dependency 'SimplyLayout/Core'
108 | end
109 |
110 | s.subspec 'Group' do |sp|
111 | sp.source_files = 'Sources/SimplyLayout/Group/**/*.{swift}'
112 | sp.dependency 'SimplyLayout/Core'
113 | end
114 |
115 |
116 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
117 | #
118 | # A list of resources included with the Pod. These are copied into the
119 | # target bundle with a build phase script. Anything else will be cleaned.
120 | # You can preserve files from being cleaned, please don't preserve
121 | # non-essential files like tests, examples and documentation.
122 | #
123 |
124 | # s.resource = "icon.png"
125 | # s.resources = "Resources/*.png"
126 |
127 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave"
128 |
129 |
130 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
131 | #
132 | # Link your library with frameworks, or libraries. Libraries do not include
133 | # the lib prefix of their name.
134 | #
135 |
136 | s.framework = "UIKit"
137 | # s.frameworks = "SomeFramework", "AnotherFramework"
138 |
139 | # s.library = "iconv"
140 | # s.libraries = "iconv", "xml2"
141 |
142 |
143 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
144 | #
145 | # If your library depends on compiler flags you can set them in the xcconfig hash
146 | # where they will only apply to your library. If you depend on other Podspecs
147 | # you can include multiple dependencies to ensure it works.
148 |
149 | # s.requires_arc = true
150 |
151 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
152 | # s.dependency "JSONKit", "~> 1.4"
153 |
154 | end
155 |
--------------------------------------------------------------------------------
/SimplyLayout.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 48;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 239416061F6B86EE003C9B80 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 239416051F6B86EE003C9B80 /* AppDelegate.swift */; };
11 | 239416081F6B86EE003C9B80 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 239416071F6B86EE003C9B80 /* ViewController.swift */; };
12 | 2394160B1F6B86EE003C9B80 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 239416091F6B86EE003C9B80 /* Main.storyboard */; };
13 | 2394160D1F6B86EF003C9B80 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2394160C1F6B86EF003C9B80 /* Assets.xcassets */; };
14 | 239416101F6B86EF003C9B80 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2394160E1F6B86EF003C9B80 /* LaunchScreen.storyboard */; };
15 | 239416201F6B86FD003C9B80 /* SimplyLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 2394161E1F6B86FD003C9B80 /* SimplyLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
16 | 239416231F6B86FD003C9B80 /* SimplyLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2394161C1F6B86FD003C9B80 /* SimplyLayout.framework */; };
17 | 239416241F6B86FD003C9B80 /* SimplyLayout.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 2394161C1F6B86FD003C9B80 /* SimplyLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
18 | 2394162A1F6B870D003C9B80 /* Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 239416291F6B870D003C9B80 /* Test.swift */; };
19 | 239A1B2421DB78E900383FA2 /* EdgeAnchor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 239A1B2321DB78E900383FA2 /* EdgeAnchor.swift */; };
20 | 239A1B2621DB82AE00383FA2 /* ConstraintGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 239A1B2521DB82AE00383FA2 /* ConstraintGroup.swift */; };
21 | 239A1B2A21DBAA9200383FA2 /* CenterAnchor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD1AAF22178550D008E0580 /* CenterAnchor.swift */; };
22 | 23ECC28E1F7E24A800CADD68 /* NSLayoutConstraintExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23ECC2871F7E24A700CADD68 /* NSLayoutConstraintExtension.swift */; };
23 | 23ECC28F1F7E24A800CADD68 /* AttributedDimension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23ECC2881F7E24A800CADD68 /* AttributedDimension.swift */; };
24 | 23ECC2901F7E24A800CADD68 /* AttributedConstant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23ECC2891F7E24A800CADD68 /* AttributedConstant.swift */; };
25 | 23ECC2911F7E24A800CADD68 /* NSLayoutAxisAnchorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23ECC28A1F7E24A800CADD68 /* NSLayoutAxisAnchorExtension.swift */; };
26 | 23ECC2921F7E24A800CADD68 /* SimplyLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23ECC28B1F7E24A800CADD68 /* SimplyLayout.swift */; };
27 | 23ECC2931F7E24A800CADD68 /* NSLayoutDimensionExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23ECC28C1F7E24A800CADD68 /* NSLayoutDimensionExtension.swift */; };
28 | 23ECC2941F7E24A800CADD68 /* AttributedAnchor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23ECC28D1F7E24A800CADD68 /* AttributedAnchor.swift */; };
29 | /* End PBXBuildFile section */
30 |
31 | /* Begin PBXContainerItemProxy section */
32 | 239416211F6B86FD003C9B80 /* PBXContainerItemProxy */ = {
33 | isa = PBXContainerItemProxy;
34 | containerPortal = 239415FA1F6B86EE003C9B80 /* Project object */;
35 | proxyType = 1;
36 | remoteGlobalIDString = 2394161B1F6B86FD003C9B80;
37 | remoteInfo = SimplyLayout;
38 | };
39 | /* End PBXContainerItemProxy section */
40 |
41 | /* Begin PBXCopyFilesBuildPhase section */
42 | 239416281F6B86FD003C9B80 /* Embed Frameworks */ = {
43 | isa = PBXCopyFilesBuildPhase;
44 | buildActionMask = 2147483647;
45 | dstPath = "";
46 | dstSubfolderSpec = 10;
47 | files = (
48 | 239416241F6B86FD003C9B80 /* SimplyLayout.framework in Embed Frameworks */,
49 | );
50 | name = "Embed Frameworks";
51 | runOnlyForDeploymentPostprocessing = 0;
52 | };
53 | /* End PBXCopyFilesBuildPhase section */
54 |
55 | /* Begin PBXFileReference section */
56 | 1CD1AAF22178550D008E0580 /* CenterAnchor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CenterAnchor.swift; sourceTree = ""; };
57 | 239416021F6B86EE003C9B80 /* SimplyLayoutDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimplyLayoutDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
58 | 239416051F6B86EE003C9B80 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
59 | 239416071F6B86EE003C9B80 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
60 | 2394160A1F6B86EE003C9B80 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
61 | 2394160C1F6B86EF003C9B80 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
62 | 2394160F1F6B86EF003C9B80 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
63 | 239416111F6B86EF003C9B80 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
64 | 2394161C1F6B86FD003C9B80 /* SimplyLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SimplyLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; };
65 | 2394161E1F6B86FD003C9B80 /* SimplyLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SimplyLayout.h; sourceTree = ""; };
66 | 2394161F1F6B86FD003C9B80 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
67 | 239416291F6B870D003C9B80 /* Test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Test.swift; sourceTree = ""; };
68 | 239A1B2321DB78E900383FA2 /* EdgeAnchor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EdgeAnchor.swift; sourceTree = ""; };
69 | 239A1B2521DB82AE00383FA2 /* ConstraintGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintGroup.swift; sourceTree = ""; };
70 | 23ECC2871F7E24A700CADD68 /* NSLayoutConstraintExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutConstraintExtension.swift; sourceTree = ""; };
71 | 23ECC2881F7E24A800CADD68 /* AttributedDimension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedDimension.swift; sourceTree = ""; };
72 | 23ECC2891F7E24A800CADD68 /* AttributedConstant.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedConstant.swift; sourceTree = ""; };
73 | 23ECC28A1F7E24A800CADD68 /* NSLayoutAxisAnchorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutAxisAnchorExtension.swift; sourceTree = ""; };
74 | 23ECC28B1F7E24A800CADD68 /* SimplyLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimplyLayout.swift; sourceTree = ""; };
75 | 23ECC28C1F7E24A800CADD68 /* NSLayoutDimensionExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLayoutDimensionExtension.swift; sourceTree = ""; };
76 | 23ECC28D1F7E24A800CADD68 /* AttributedAnchor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedAnchor.swift; sourceTree = ""; };
77 | /* End PBXFileReference section */
78 |
79 | /* Begin PBXFrameworksBuildPhase section */
80 | 239415FF1F6B86EE003C9B80 /* Frameworks */ = {
81 | isa = PBXFrameworksBuildPhase;
82 | buildActionMask = 2147483647;
83 | files = (
84 | 239416231F6B86FD003C9B80 /* SimplyLayout.framework in Frameworks */,
85 | );
86 | runOnlyForDeploymentPostprocessing = 0;
87 | };
88 | 239416181F6B86FD003C9B80 /* Frameworks */ = {
89 | isa = PBXFrameworksBuildPhase;
90 | buildActionMask = 2147483647;
91 | files = (
92 | );
93 | runOnlyForDeploymentPostprocessing = 0;
94 | };
95 | /* End PBXFrameworksBuildPhase section */
96 |
97 | /* Begin PBXGroup section */
98 | 239415F91F6B86EE003C9B80 = {
99 | isa = PBXGroup;
100 | children = (
101 | 23A7FF972BBED40800A22E95 /* Tests */,
102 | 23A7FF952BBED3C000A22E95 /* Sources */,
103 | 239416031F6B86EE003C9B80 /* Products */,
104 | );
105 | sourceTree = "";
106 | };
107 | 239416031F6B86EE003C9B80 /* Products */ = {
108 | isa = PBXGroup;
109 | children = (
110 | 239416021F6B86EE003C9B80 /* SimplyLayoutDemo.app */,
111 | 2394161C1F6B86FD003C9B80 /* SimplyLayout.framework */,
112 | );
113 | name = Products;
114 | sourceTree = "";
115 | };
116 | 239416041F6B86EE003C9B80 /* SimplyLayoutDemo */ = {
117 | isa = PBXGroup;
118 | children = (
119 | 239416051F6B86EE003C9B80 /* AppDelegate.swift */,
120 | 239416071F6B86EE003C9B80 /* ViewController.swift */,
121 | 239416091F6B86EE003C9B80 /* Main.storyboard */,
122 | 2394160C1F6B86EF003C9B80 /* Assets.xcassets */,
123 | 2394160E1F6B86EF003C9B80 /* LaunchScreen.storyboard */,
124 | 239416111F6B86EF003C9B80 /* Info.plist */,
125 | );
126 | path = SimplyLayoutDemo;
127 | sourceTree = "";
128 | };
129 | 239A1B2721DB8DA100383FA2 /* Core */ = {
130 | isa = PBXGroup;
131 | children = (
132 | 23ECC28B1F7E24A800CADD68 /* SimplyLayout.swift */,
133 | 23ECC28D1F7E24A800CADD68 /* AttributedAnchor.swift */,
134 | 23ECC2891F7E24A800CADD68 /* AttributedConstant.swift */,
135 | 23ECC2881F7E24A800CADD68 /* AttributedDimension.swift */,
136 | 23ECC28A1F7E24A800CADD68 /* NSLayoutAxisAnchorExtension.swift */,
137 | 23ECC2871F7E24A700CADD68 /* NSLayoutConstraintExtension.swift */,
138 | 23ECC28C1F7E24A800CADD68 /* NSLayoutDimensionExtension.swift */,
139 | );
140 | path = Core;
141 | sourceTree = "";
142 | };
143 | 239A1B2821DB8DC400383FA2 /* Anchor */ = {
144 | isa = PBXGroup;
145 | children = (
146 | 1CD1AAF22178550D008E0580 /* CenterAnchor.swift */,
147 | 239A1B2321DB78E900383FA2 /* EdgeAnchor.swift */,
148 | );
149 | path = Anchor;
150 | sourceTree = "";
151 | };
152 | 239A1B2921DB8DD900383FA2 /* Group */ = {
153 | isa = PBXGroup;
154 | children = (
155 | 239A1B2521DB82AE00383FA2 /* ConstraintGroup.swift */,
156 | );
157 | path = Group;
158 | sourceTree = "";
159 | };
160 | 23A7FF952BBED3C000A22E95 /* Sources */ = {
161 | isa = PBXGroup;
162 | children = (
163 | 239416041F6B86EE003C9B80 /* SimplyLayoutDemo */,
164 | 23A7FF982BBED54A00A22E95 /* SimplyLayout */,
165 | );
166 | path = Sources;
167 | sourceTree = "";
168 | };
169 | 23A7FF972BBED40800A22E95 /* Tests */ = {
170 | isa = PBXGroup;
171 | children = (
172 | 239416291F6B870D003C9B80 /* Test.swift */,
173 | );
174 | path = Tests;
175 | sourceTree = "";
176 | };
177 | 23A7FF982BBED54A00A22E95 /* SimplyLayout */ = {
178 | isa = PBXGroup;
179 | children = (
180 | 2394161E1F6B86FD003C9B80 /* SimplyLayout.h */,
181 | 2394161F1F6B86FD003C9B80 /* Info.plist */,
182 | 239A1B2721DB8DA100383FA2 /* Core */,
183 | 239A1B2821DB8DC400383FA2 /* Anchor */,
184 | 239A1B2921DB8DD900383FA2 /* Group */,
185 | );
186 | path = SimplyLayout;
187 | sourceTree = "";
188 | };
189 | /* End PBXGroup section */
190 |
191 | /* Begin PBXHeadersBuildPhase section */
192 | 239416191F6B86FD003C9B80 /* Headers */ = {
193 | isa = PBXHeadersBuildPhase;
194 | buildActionMask = 2147483647;
195 | files = (
196 | 239416201F6B86FD003C9B80 /* SimplyLayout.h in Headers */,
197 | );
198 | runOnlyForDeploymentPostprocessing = 0;
199 | };
200 | /* End PBXHeadersBuildPhase section */
201 |
202 | /* Begin PBXNativeTarget section */
203 | 239416011F6B86EE003C9B80 /* SimplyLayoutDemo */ = {
204 | isa = PBXNativeTarget;
205 | buildConfigurationList = 239416141F6B86EF003C9B80 /* Build configuration list for PBXNativeTarget "SimplyLayoutDemo" */;
206 | buildPhases = (
207 | 239415FE1F6B86EE003C9B80 /* Sources */,
208 | 239415FF1F6B86EE003C9B80 /* Frameworks */,
209 | 239416001F6B86EE003C9B80 /* Resources */,
210 | 239416281F6B86FD003C9B80 /* Embed Frameworks */,
211 | );
212 | buildRules = (
213 | );
214 | dependencies = (
215 | 239416221F6B86FD003C9B80 /* PBXTargetDependency */,
216 | );
217 | name = SimplyLayoutDemo;
218 | productName = SimplyLayoutDemo;
219 | productReference = 239416021F6B86EE003C9B80 /* SimplyLayoutDemo.app */;
220 | productType = "com.apple.product-type.application";
221 | };
222 | 2394161B1F6B86FD003C9B80 /* SimplyLayout */ = {
223 | isa = PBXNativeTarget;
224 | buildConfigurationList = 239416251F6B86FD003C9B80 /* Build configuration list for PBXNativeTarget "SimplyLayout" */;
225 | buildPhases = (
226 | 239416171F6B86FD003C9B80 /* Sources */,
227 | 239416181F6B86FD003C9B80 /* Frameworks */,
228 | 239416191F6B86FD003C9B80 /* Headers */,
229 | 2394161A1F6B86FD003C9B80 /* Resources */,
230 | );
231 | buildRules = (
232 | );
233 | dependencies = (
234 | );
235 | name = SimplyLayout;
236 | productName = SimplyLayout;
237 | productReference = 2394161C1F6B86FD003C9B80 /* SimplyLayout.framework */;
238 | productType = "com.apple.product-type.framework";
239 | };
240 | /* End PBXNativeTarget section */
241 |
242 | /* Begin PBXProject section */
243 | 239415FA1F6B86EE003C9B80 /* Project object */ = {
244 | isa = PBXProject;
245 | attributes = {
246 | LastSwiftUpdateCheck = 0900;
247 | LastUpgradeCheck = 1030;
248 | ORGANIZATIONNAME = aipeople;
249 | TargetAttributes = {
250 | 239416011F6B86EE003C9B80 = {
251 | CreatedOnToolsVersion = 9.0;
252 | LastSwiftMigration = 1030;
253 | ProvisioningStyle = Automatic;
254 | };
255 | 2394161B1F6B86FD003C9B80 = {
256 | CreatedOnToolsVersion = 9.0;
257 | LastSwiftMigration = 1030;
258 | ProvisioningStyle = Automatic;
259 | };
260 | };
261 | };
262 | buildConfigurationList = 239415FD1F6B86EE003C9B80 /* Build configuration list for PBXProject "SimplyLayout" */;
263 | compatibilityVersion = "Xcode 8.0";
264 | developmentRegion = en;
265 | hasScannedForEncodings = 0;
266 | knownRegions = (
267 | en,
268 | Base,
269 | );
270 | mainGroup = 239415F91F6B86EE003C9B80;
271 | productRefGroup = 239416031F6B86EE003C9B80 /* Products */;
272 | projectDirPath = "";
273 | projectRoot = "";
274 | targets = (
275 | 239416011F6B86EE003C9B80 /* SimplyLayoutDemo */,
276 | 2394161B1F6B86FD003C9B80 /* SimplyLayout */,
277 | );
278 | };
279 | /* End PBXProject section */
280 |
281 | /* Begin PBXResourcesBuildPhase section */
282 | 239416001F6B86EE003C9B80 /* Resources */ = {
283 | isa = PBXResourcesBuildPhase;
284 | buildActionMask = 2147483647;
285 | files = (
286 | 239416101F6B86EF003C9B80 /* LaunchScreen.storyboard in Resources */,
287 | 2394160D1F6B86EF003C9B80 /* Assets.xcassets in Resources */,
288 | 2394160B1F6B86EE003C9B80 /* Main.storyboard in Resources */,
289 | );
290 | runOnlyForDeploymentPostprocessing = 0;
291 | };
292 | 2394161A1F6B86FD003C9B80 /* Resources */ = {
293 | isa = PBXResourcesBuildPhase;
294 | buildActionMask = 2147483647;
295 | files = (
296 | );
297 | runOnlyForDeploymentPostprocessing = 0;
298 | };
299 | /* End PBXResourcesBuildPhase section */
300 |
301 | /* Begin PBXSourcesBuildPhase section */
302 | 239415FE1F6B86EE003C9B80 /* Sources */ = {
303 | isa = PBXSourcesBuildPhase;
304 | buildActionMask = 2147483647;
305 | files = (
306 | 239416081F6B86EE003C9B80 /* ViewController.swift in Sources */,
307 | 239416061F6B86EE003C9B80 /* AppDelegate.swift in Sources */,
308 | );
309 | runOnlyForDeploymentPostprocessing = 0;
310 | };
311 | 239416171F6B86FD003C9B80 /* Sources */ = {
312 | isa = PBXSourcesBuildPhase;
313 | buildActionMask = 2147483647;
314 | files = (
315 | 2394162A1F6B870D003C9B80 /* Test.swift in Sources */,
316 | 23ECC2901F7E24A800CADD68 /* AttributedConstant.swift in Sources */,
317 | 23ECC2931F7E24A800CADD68 /* NSLayoutDimensionExtension.swift in Sources */,
318 | 23ECC28F1F7E24A800CADD68 /* AttributedDimension.swift in Sources */,
319 | 239A1B2621DB82AE00383FA2 /* ConstraintGroup.swift in Sources */,
320 | 23ECC2941F7E24A800CADD68 /* AttributedAnchor.swift in Sources */,
321 | 23ECC28E1F7E24A800CADD68 /* NSLayoutConstraintExtension.swift in Sources */,
322 | 239A1B2421DB78E900383FA2 /* EdgeAnchor.swift in Sources */,
323 | 239A1B2A21DBAA9200383FA2 /* CenterAnchor.swift in Sources */,
324 | 23ECC2911F7E24A800CADD68 /* NSLayoutAxisAnchorExtension.swift in Sources */,
325 | 23ECC2921F7E24A800CADD68 /* SimplyLayout.swift in Sources */,
326 | );
327 | runOnlyForDeploymentPostprocessing = 0;
328 | };
329 | /* End PBXSourcesBuildPhase section */
330 |
331 | /* Begin PBXTargetDependency section */
332 | 239416221F6B86FD003C9B80 /* PBXTargetDependency */ = {
333 | isa = PBXTargetDependency;
334 | target = 2394161B1F6B86FD003C9B80 /* SimplyLayout */;
335 | targetProxy = 239416211F6B86FD003C9B80 /* PBXContainerItemProxy */;
336 | };
337 | /* End PBXTargetDependency section */
338 |
339 | /* Begin PBXVariantGroup section */
340 | 239416091F6B86EE003C9B80 /* Main.storyboard */ = {
341 | isa = PBXVariantGroup;
342 | children = (
343 | 2394160A1F6B86EE003C9B80 /* Base */,
344 | );
345 | name = Main.storyboard;
346 | sourceTree = "";
347 | };
348 | 2394160E1F6B86EF003C9B80 /* LaunchScreen.storyboard */ = {
349 | isa = PBXVariantGroup;
350 | children = (
351 | 2394160F1F6B86EF003C9B80 /* Base */,
352 | );
353 | name = LaunchScreen.storyboard;
354 | sourceTree = "";
355 | };
356 | /* End PBXVariantGroup section */
357 |
358 | /* Begin XCBuildConfiguration section */
359 | 239416121F6B86EF003C9B80 /* Debug */ = {
360 | isa = XCBuildConfiguration;
361 | buildSettings = {
362 | ALWAYS_SEARCH_USER_PATHS = NO;
363 | CLANG_ANALYZER_NONNULL = YES;
364 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
365 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
366 | CLANG_CXX_LIBRARY = "libc++";
367 | CLANG_ENABLE_MODULES = YES;
368 | CLANG_ENABLE_OBJC_ARC = YES;
369 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
370 | CLANG_WARN_BOOL_CONVERSION = YES;
371 | CLANG_WARN_COMMA = YES;
372 | CLANG_WARN_CONSTANT_CONVERSION = YES;
373 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
374 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
375 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
376 | CLANG_WARN_EMPTY_BODY = YES;
377 | CLANG_WARN_ENUM_CONVERSION = YES;
378 | CLANG_WARN_INFINITE_RECURSION = YES;
379 | CLANG_WARN_INT_CONVERSION = YES;
380 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
381 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
382 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
383 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
384 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
385 | CLANG_WARN_STRICT_PROTOTYPES = YES;
386 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
387 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
388 | CLANG_WARN_UNREACHABLE_CODE = YES;
389 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
390 | CODE_SIGN_IDENTITY = "iPhone Developer";
391 | COPY_PHASE_STRIP = NO;
392 | DEBUG_INFORMATION_FORMAT = dwarf;
393 | ENABLE_STRICT_OBJC_MSGSEND = YES;
394 | ENABLE_TESTABILITY = YES;
395 | GCC_C_LANGUAGE_STANDARD = gnu11;
396 | GCC_DYNAMIC_NO_PIC = NO;
397 | GCC_NO_COMMON_BLOCKS = YES;
398 | GCC_OPTIMIZATION_LEVEL = 0;
399 | GCC_PREPROCESSOR_DEFINITIONS = (
400 | "DEBUG=1",
401 | "$(inherited)",
402 | );
403 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
404 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
405 | GCC_WARN_UNDECLARED_SELECTOR = YES;
406 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
407 | GCC_WARN_UNUSED_FUNCTION = YES;
408 | GCC_WARN_UNUSED_VARIABLE = YES;
409 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
410 | MTL_ENABLE_DEBUG_INFO = YES;
411 | ONLY_ACTIVE_ARCH = YES;
412 | SDKROOT = iphoneos;
413 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
414 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
415 | };
416 | name = Debug;
417 | };
418 | 239416131F6B86EF003C9B80 /* Release */ = {
419 | isa = XCBuildConfiguration;
420 | buildSettings = {
421 | ALWAYS_SEARCH_USER_PATHS = NO;
422 | CLANG_ANALYZER_NONNULL = YES;
423 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
424 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
425 | CLANG_CXX_LIBRARY = "libc++";
426 | CLANG_ENABLE_MODULES = YES;
427 | CLANG_ENABLE_OBJC_ARC = YES;
428 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
429 | CLANG_WARN_BOOL_CONVERSION = YES;
430 | CLANG_WARN_COMMA = YES;
431 | CLANG_WARN_CONSTANT_CONVERSION = YES;
432 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
433 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
434 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
435 | CLANG_WARN_EMPTY_BODY = YES;
436 | CLANG_WARN_ENUM_CONVERSION = YES;
437 | CLANG_WARN_INFINITE_RECURSION = YES;
438 | CLANG_WARN_INT_CONVERSION = YES;
439 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
440 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
441 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
442 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
443 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
444 | CLANG_WARN_STRICT_PROTOTYPES = YES;
445 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
446 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
447 | CLANG_WARN_UNREACHABLE_CODE = YES;
448 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
449 | CODE_SIGN_IDENTITY = "iPhone Developer";
450 | COPY_PHASE_STRIP = NO;
451 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
452 | ENABLE_NS_ASSERTIONS = NO;
453 | ENABLE_STRICT_OBJC_MSGSEND = YES;
454 | GCC_C_LANGUAGE_STANDARD = gnu11;
455 | GCC_NO_COMMON_BLOCKS = YES;
456 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
457 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
458 | GCC_WARN_UNDECLARED_SELECTOR = YES;
459 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
460 | GCC_WARN_UNUSED_FUNCTION = YES;
461 | GCC_WARN_UNUSED_VARIABLE = YES;
462 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
463 | MTL_ENABLE_DEBUG_INFO = NO;
464 | SDKROOT = iphoneos;
465 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
466 | VALIDATE_PRODUCT = YES;
467 | };
468 | name = Release;
469 | };
470 | 239416151F6B86EF003C9B80 /* Debug */ = {
471 | isa = XCBuildConfiguration;
472 | buildSettings = {
473 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
474 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
475 | CODE_SIGN_STYLE = Automatic;
476 | DEVELOPMENT_TEAM = QY89NMKNE7;
477 | INFOPLIST_FILE = Sources/SimplyLayoutDemo/Info.plist;
478 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
479 | PRODUCT_BUNDLE_IDENTIFIER = com.aipeople.SimplyLayoutDemo;
480 | PRODUCT_NAME = "$(TARGET_NAME)";
481 | SWIFT_VERSION = 5.0;
482 | TARGETED_DEVICE_FAMILY = "1,2";
483 | };
484 | name = Debug;
485 | };
486 | 239416161F6B86EF003C9B80 /* Release */ = {
487 | isa = XCBuildConfiguration;
488 | buildSettings = {
489 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
490 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
491 | CODE_SIGN_STYLE = Automatic;
492 | DEVELOPMENT_TEAM = QY89NMKNE7;
493 | INFOPLIST_FILE = Sources/SimplyLayoutDemo/Info.plist;
494 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
495 | PRODUCT_BUNDLE_IDENTIFIER = com.aipeople.SimplyLayoutDemo;
496 | PRODUCT_NAME = "$(TARGET_NAME)";
497 | SWIFT_VERSION = 5.0;
498 | TARGETED_DEVICE_FAMILY = "1,2";
499 | };
500 | name = Release;
501 | };
502 | 239416261F6B86FD003C9B80 /* Debug */ = {
503 | isa = XCBuildConfiguration;
504 | buildSettings = {
505 | CLANG_ENABLE_MODULES = YES;
506 | CODE_SIGN_IDENTITY = "";
507 | CODE_SIGN_STYLE = Automatic;
508 | CURRENT_PROJECT_VERSION = 1;
509 | DEFINES_MODULE = YES;
510 | DEVELOPMENT_TEAM = QY89NMKNE7;
511 | DYLIB_COMPATIBILITY_VERSION = 1;
512 | DYLIB_CURRENT_VERSION = 1;
513 | DYLIB_INSTALL_NAME_BASE = "@rpath";
514 | INFOPLIST_FILE = Sources/SimplyLayout/Info.plist;
515 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
516 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
517 | PRODUCT_BUNDLE_IDENTIFIER = com.aipeople.SimplyLayout;
518 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
519 | SKIP_INSTALL = YES;
520 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
521 | SWIFT_VERSION = 5.0;
522 | TARGETED_DEVICE_FAMILY = "1,2";
523 | VERSIONING_SYSTEM = "apple-generic";
524 | VERSION_INFO_PREFIX = "";
525 | };
526 | name = Debug;
527 | };
528 | 239416271F6B86FD003C9B80 /* Release */ = {
529 | isa = XCBuildConfiguration;
530 | buildSettings = {
531 | CLANG_ENABLE_MODULES = YES;
532 | CODE_SIGN_IDENTITY = "";
533 | CODE_SIGN_STYLE = Automatic;
534 | CURRENT_PROJECT_VERSION = 1;
535 | DEFINES_MODULE = YES;
536 | DEVELOPMENT_TEAM = QY89NMKNE7;
537 | DYLIB_COMPATIBILITY_VERSION = 1;
538 | DYLIB_CURRENT_VERSION = 1;
539 | DYLIB_INSTALL_NAME_BASE = "@rpath";
540 | INFOPLIST_FILE = Sources/SimplyLayout/Info.plist;
541 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
542 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
543 | PRODUCT_BUNDLE_IDENTIFIER = com.aipeople.SimplyLayout;
544 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
545 | SKIP_INSTALL = YES;
546 | SWIFT_VERSION = 5.0;
547 | TARGETED_DEVICE_FAMILY = "1,2";
548 | VERSIONING_SYSTEM = "apple-generic";
549 | VERSION_INFO_PREFIX = "";
550 | };
551 | name = Release;
552 | };
553 | /* End XCBuildConfiguration section */
554 |
555 | /* Begin XCConfigurationList section */
556 | 239415FD1F6B86EE003C9B80 /* Build configuration list for PBXProject "SimplyLayout" */ = {
557 | isa = XCConfigurationList;
558 | buildConfigurations = (
559 | 239416121F6B86EF003C9B80 /* Debug */,
560 | 239416131F6B86EF003C9B80 /* Release */,
561 | );
562 | defaultConfigurationIsVisible = 0;
563 | defaultConfigurationName = Release;
564 | };
565 | 239416141F6B86EF003C9B80 /* Build configuration list for PBXNativeTarget "SimplyLayoutDemo" */ = {
566 | isa = XCConfigurationList;
567 | buildConfigurations = (
568 | 239416151F6B86EF003C9B80 /* Debug */,
569 | 239416161F6B86EF003C9B80 /* Release */,
570 | );
571 | defaultConfigurationIsVisible = 0;
572 | defaultConfigurationName = Release;
573 | };
574 | 239416251F6B86FD003C9B80 /* Build configuration list for PBXNativeTarget "SimplyLayout" */ = {
575 | isa = XCConfigurationList;
576 | buildConfigurations = (
577 | 239416261F6B86FD003C9B80 /* Debug */,
578 | 239416271F6B86FD003C9B80 /* Release */,
579 | );
580 | defaultConfigurationIsVisible = 0;
581 | defaultConfigurationName = Release;
582 | };
583 | /* End XCConfigurationList section */
584 | };
585 | rootObject = 239415FA1F6B86EE003C9B80 /* Project object */;
586 | }
587 |
--------------------------------------------------------------------------------
/SimplyLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SimplyLayout.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SimplyLayout.xcodeproj/xcshareddata/xcschemes/SimplyLayout.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
43 |
44 |
50 |
51 |
57 |
58 |
59 |
60 |
62 |
63 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Anchor/CenterAnchor.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CenterAnchor.swift
3 | // SimplyLayout
4 | //
5 | // Created by Sean, Su on 2019/1/1.
6 | // Copyright © 2019 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | public struct CenterAnchor {
13 |
14 | let xAnchor: NSLayoutXAxisAnchor
15 | let yAnchor: NSLayoutYAxisAnchor
16 | let constant: CGPoint
17 |
18 | fileprivate init(xAnchor: NSLayoutXAxisAnchor, yAnchor: NSLayoutYAxisAnchor, constant: CGPoint) {
19 | self.xAnchor = xAnchor
20 | self.yAnchor = yAnchor
21 | self.constant = constant
22 | }
23 | }
24 |
25 |
26 | extension CenterAnchor {
27 |
28 | @discardableResult
29 | public static func ==(lhs: CenterAnchor, rhs: CenterAnchor) -> [NSLayoutConstraint] {
30 |
31 | return [
32 | lhs.xAnchor == rhs.xAnchor + (rhs.constant.x - lhs.constant.x),
33 | lhs.yAnchor == rhs.yAnchor + (rhs.constant.y - lhs.constant.y)
34 | ]
35 | }
36 |
37 | @discardableResult
38 | public static func +(lhs: CenterAnchor, constant: CGPoint) -> CenterAnchor {
39 | return CenterAnchor(
40 | xAnchor: lhs.xAnchor,
41 | yAnchor: lhs.yAnchor,
42 | constant: CGPoint(
43 | x: lhs.constant.x + constant.x,
44 | y: lhs.constant.y + constant.y
45 | ))
46 | }
47 | }
48 |
49 |
50 | extension UIView {
51 |
52 | public var centerAnchor: CenterAnchor {
53 | return CenterAnchor(xAnchor: centerXAnchor, yAnchor: centerYAnchor, constant: .zero)
54 | }
55 | }
56 |
57 |
58 | @available(iOS 9.0, *)
59 | extension UILayoutGuide {
60 |
61 | public var centerAnchor: CenterAnchor {
62 | return CenterAnchor(xAnchor: centerXAnchor, yAnchor: centerYAnchor, constant: .zero)
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Anchor/EdgeAnchor.swift:
--------------------------------------------------------------------------------
1 | //
2 | // EdgeAnchor.swift
3 | // SimplyLayout
4 | //
5 | // Created by Sean, Su on 2019/1/1.
6 | // Copyright © 2019 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | public struct EdgeAnchor {
13 |
14 | let topAnchor: NSLayoutYAxisAnchor
15 | let bottomAnchor: NSLayoutYAxisAnchor
16 | let leadingAnchor: NSLayoutXAxisAnchor
17 | let trailingAnchor: NSLayoutXAxisAnchor
18 | let insets: UIEdgeInsets
19 |
20 | public init(top: NSLayoutYAxisAnchor, leading: NSLayoutXAxisAnchor, bottom: NSLayoutYAxisAnchor, trailing: NSLayoutXAxisAnchor, insets: UIEdgeInsets) {
21 |
22 | self.topAnchor = top
23 | self.leadingAnchor = leading
24 | self.bottomAnchor = bottom
25 | self.trailingAnchor = trailing
26 | self.insets = insets
27 | }
28 |
29 | public func insetBy(top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> EdgeAnchor {
30 |
31 | return EdgeAnchor(
32 | top: topAnchor,
33 | leading: leadingAnchor,
34 | bottom: bottomAnchor,
35 | trailing: trailingAnchor,
36 | insets: UIEdgeInsets(
37 | top: insets.top + top,
38 | left: insets.left + left,
39 | bottom: insets.bottom + bottom,
40 | right: insets.right + right
41 | ))
42 | }
43 |
44 | public func insetBy(_ insets: UIEdgeInsets) -> EdgeAnchor {
45 |
46 | return insetBy(top: insets.top, left: insets.left, bottom: insets.bottom, right: insets.right)
47 | }
48 | }
49 |
50 |
51 | extension EdgeAnchor {
52 |
53 | @discardableResult
54 | public static func ==(lhs: EdgeAnchor, rhs: EdgeAnchor) -> [NSLayoutConstraint] {
55 |
56 | return [
57 | lhs.topAnchor == rhs.topAnchor + (rhs.insets.top - lhs.insets.top),
58 | lhs.leadingAnchor == rhs.leadingAnchor + (rhs.insets.left - lhs.insets.left),
59 | lhs.bottomAnchor == rhs.bottomAnchor - (rhs.insets.bottom - lhs.insets.bottom),
60 | lhs.trailingAnchor == rhs.trailingAnchor - (rhs.insets.right - lhs.insets.right),
61 | ]
62 | }
63 |
64 | @discardableResult
65 | public static func <=(lhs: EdgeAnchor, rhs: EdgeAnchor) -> [NSLayoutConstraint] {
66 |
67 | return [
68 | lhs.topAnchor >= rhs.topAnchor + (rhs.insets.top - lhs.insets.top),
69 | lhs.leadingAnchor >= rhs.leadingAnchor + (rhs.insets.left - lhs.insets.left),
70 | lhs.bottomAnchor <= rhs.bottomAnchor - (rhs.insets.bottom - lhs.insets.bottom),
71 | lhs.trailingAnchor <= rhs.trailingAnchor - (rhs.insets.right - lhs.insets.right),
72 | ]
73 | }
74 |
75 | @discardableResult
76 | public static func >=(lhs: EdgeAnchor, rhs: EdgeAnchor) -> [NSLayoutConstraint] {
77 |
78 | return [
79 | lhs.topAnchor <= rhs.topAnchor + (rhs.insets.top - lhs.insets.top),
80 | lhs.leadingAnchor <= rhs.leadingAnchor + (rhs.insets.left - lhs.insets.left),
81 | lhs.bottomAnchor >= rhs.bottomAnchor - (rhs.insets.bottom - lhs.insets.bottom),
82 | lhs.trailingAnchor >= rhs.trailingAnchor - (rhs.insets.right - lhs.insets.right),
83 | ]
84 | }
85 |
86 | @discardableResult
87 | public static func +(lhs: EdgeAnchor, rhs: UIEdgeInsets) -> EdgeAnchor {
88 |
89 | return lhs.insetBy(rhs)
90 | }
91 | }
92 |
93 |
94 | extension UIView {
95 |
96 | public var edgeAnchor: EdgeAnchor {
97 | return EdgeAnchor(
98 | top: topAnchor,
99 | leading: leadingAnchor,
100 | bottom: bottomAnchor,
101 | trailing: trailingAnchor,
102 | insets: .zero
103 | )
104 | }
105 |
106 | @available(iOS 11.0, *)
107 | public var safeAreaEdgeAnchor: EdgeAnchor {
108 | return EdgeAnchor(
109 | top: safeAreaLayoutGuide.topAnchor,
110 | leading: safeAreaLayoutGuide.leadingAnchor,
111 | bottom: safeAreaLayoutGuide.bottomAnchor,
112 | trailing: safeAreaLayoutGuide.trailingAnchor,
113 | insets: .zero
114 | )
115 | }
116 | }
117 |
118 |
119 | @available(iOS 9.0, *)
120 | extension UILayoutGuide {
121 |
122 | public var edgeAnchor: EdgeAnchor {
123 | return EdgeAnchor(
124 | top: topAnchor,
125 | leading: leadingAnchor,
126 | bottom: bottomAnchor,
127 | trailing: trailingAnchor,
128 | insets: .zero
129 | )
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Core/AttributedAnchor.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AttributedAnchor.swift
3 | // SimplyLayout
4 | //
5 | // Created by aipeople on 27/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | public struct AttributedAnchor where AnchorType: AnyObject {
13 |
14 | public let anchor: NSLayoutAnchor
15 | public var priority: UILayoutPriority
16 | public var constant: CGFloat
17 | public var shouldActivate: Bool
18 |
19 | init(anchor: NSLayoutAnchor,
20 | constant: CGFloat,
21 | priority: UILayoutPriority = SimplyLayout.config.defaultPriority,
22 | shouldActivate: Bool = SimplyLayout.config.defaultActivation) {
23 |
24 | self.anchor = anchor
25 | self.constant = constant
26 | self.priority = priority
27 | self.shouldActivate = shouldActivate
28 | }
29 | }
30 |
31 | extension AttributedAnchor {
32 |
33 | public static func +(lhs: AttributedAnchor, rhs: CGFloat) -> AttributedAnchor {
34 |
35 | var anchor = lhs
36 | anchor.constant += rhs
37 | return anchor
38 | }
39 |
40 | public static func -(lhs: AttributedAnchor, rhs: CGFloat) -> AttributedAnchor {
41 |
42 | return lhs + -rhs
43 | }
44 | }
45 |
46 |
47 | infix operator ~: SimplyLayoutPriorityPrecedenceGroup
48 |
49 | extension AttributedAnchor {
50 |
51 | public static func ~(lhs: AttributedAnchor, rhs: Float) -> AttributedAnchor {
52 |
53 | return lhs ~ UILayoutPriority(rawValue: rhs)
54 | }
55 |
56 | public static func ~(lhs: AttributedAnchor, rhs: UILayoutPriority) -> AttributedAnchor {
57 |
58 | var anchor = lhs
59 | anchor.priority = rhs
60 | return anchor
61 | }
62 | }
63 |
64 |
65 | prefix operator ++
66 | prefix operator --
67 |
68 | extension AttributedAnchor {
69 |
70 | public static prefix func --(lhs: AttributedAnchor) -> AttributedAnchor {
71 |
72 | guard lhs.shouldActivate else {
73 | return lhs
74 | }
75 |
76 | var anchor = lhs
77 | anchor.shouldActivate = false
78 | return anchor
79 | }
80 |
81 | public static prefix func ++(lhs: AttributedAnchor) -> AttributedAnchor {
82 |
83 | guard !lhs.shouldActivate else {
84 | return lhs
85 | }
86 |
87 | var anchor = lhs
88 | anchor.shouldActivate = true
89 | return anchor
90 | }
91 | }
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Core/AttributedConstant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AttributedConstant.swift
3 | // SimplyLayout
4 | //
5 | // Created by aipeople on 28/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | public struct AttributedConstant {
13 |
14 | public var constant: CGFloat
15 | public var priority: UILayoutPriority
16 | public var shouldActivate: Bool
17 |
18 | init(constant: CGFloat,
19 | priority: UILayoutPriority = SimplyLayout.config.defaultPriority,
20 | shouldActivate: Bool = SimplyLayout.config.defaultActivation) {
21 |
22 | self.constant = constant
23 | self.priority = priority
24 | self.shouldActivate = shouldActivate
25 | }
26 | }
27 |
28 |
29 | extension CGFloat {
30 |
31 | public static func ~(lhs: CGFloat, rhs: Float) -> AttributedConstant {
32 |
33 | return lhs ~ UILayoutPriority(rhs)
34 | }
35 |
36 | public static func ~(lhs: CGFloat, rhs: UILayoutPriority) -> AttributedConstant {
37 |
38 | return AttributedConstant(constant: lhs, priority: rhs)
39 | }
40 |
41 | public static prefix func --(lhs: CGFloat) -> AttributedConstant {
42 |
43 | return AttributedConstant(constant: lhs, shouldActivate: false)
44 | }
45 |
46 | public static prefix func ++(lhs: CGFloat) -> AttributedConstant {
47 |
48 | return AttributedConstant(constant: lhs, shouldActivate: true)
49 | }
50 | }
51 |
52 | extension AttributedConstant {
53 |
54 | public static prefix func --(lhs: AttributedConstant) -> AttributedConstant {
55 |
56 | guard lhs.shouldActivate else {
57 | return lhs
58 | }
59 |
60 | var anchor = lhs
61 | anchor.shouldActivate = false
62 | return anchor
63 | }
64 |
65 | public static prefix func ++(lhs: AttributedConstant) -> AttributedConstant {
66 |
67 | guard !lhs.shouldActivate else {
68 | return lhs
69 | }
70 |
71 | var anchor = lhs
72 | anchor.shouldActivate = true
73 | return anchor
74 | }
75 | }
76 |
77 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Core/AttributedDimension.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AttributedDimension.swift
3 | // SimplyLayout
4 | //
5 | // Created by aipeople on 28/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | public struct AttributedDimension {
13 |
14 | public let dimension: NSLayoutDimension
15 | public var priority: UILayoutPriority
16 | public var multiplier: CGFloat
17 | public var constant: CGFloat
18 | public var shouldActivate: Bool
19 |
20 | init(dimension: NSLayoutDimension,
21 | multiplier: CGFloat,
22 | constant: CGFloat,
23 | priority: UILayoutPriority = SimplyLayout.config.defaultPriority,
24 | shouldActivate: Bool = SimplyLayout.config.defaultActivation) {
25 |
26 | self.dimension = dimension
27 | self.multiplier = multiplier
28 | self.constant = constant
29 | self.priority = priority
30 | self.shouldActivate = shouldActivate
31 | }
32 | }
33 |
34 |
35 | extension AttributedDimension {
36 |
37 | public static func +(lhs: AttributedDimension, rhs: CGFloat) -> AttributedDimension {
38 |
39 | var dimension = lhs
40 | dimension.constant += rhs
41 | return dimension
42 | }
43 |
44 | public static func -(lhs: AttributedDimension, rhs: CGFloat) -> AttributedDimension {
45 |
46 | return lhs + -rhs
47 | }
48 | }
49 |
50 |
51 | extension AttributedDimension {
52 |
53 | public static func *(lhs: AttributedDimension, rhs: CGFloat) -> AttributedDimension {
54 |
55 | var dimension = lhs
56 | dimension.multiplier *= rhs
57 | return dimension
58 | }
59 | }
60 |
61 |
62 | extension AttributedDimension {
63 |
64 | public static func ~(lhs: AttributedDimension, rhs: Float) -> AttributedDimension {
65 |
66 | return lhs ~ UILayoutPriority(rhs)
67 | }
68 |
69 | public static func ~(lhs: AttributedDimension, rhs: UILayoutPriority) -> AttributedDimension {
70 |
71 | var dimension = lhs
72 | dimension.priority = rhs
73 | return dimension
74 | }
75 | }
76 |
77 | extension AttributedDimension {
78 |
79 | public static prefix func --(lhs: AttributedDimension) -> AttributedDimension {
80 |
81 | guard lhs.shouldActivate else {
82 | return lhs
83 | }
84 |
85 | var anchor = lhs
86 | anchor.shouldActivate = false
87 | return anchor
88 | }
89 |
90 | public static prefix func ++(lhs: AttributedDimension) -> AttributedDimension {
91 |
92 | guard !lhs.shouldActivate else {
93 | return lhs
94 | }
95 |
96 | var anchor = lhs
97 | anchor.shouldActivate = true
98 | return anchor
99 | }
100 | }
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Core/NSLayoutAxisAnchorExtension.swift:
--------------------------------------------------------------------------------
1 | //
2 | // OperatorDifinition.swift
3 | // SimplyLayout
4 | //
5 | // Created by aipeople on 15/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | extension NSLayoutXAxisAnchor {
13 |
14 | @discardableResult
15 | public static func ==(lhs: NSLayoutXAxisAnchor, rhs: NSLayoutXAxisAnchor) -> NSLayoutConstraint {
16 |
17 | return lhs.constraint(equalTo: rhs).setup()
18 | }
19 |
20 | @discardableResult
21 | public static func <=(lhs: NSLayoutXAxisAnchor, rhs: NSLayoutXAxisAnchor) -> NSLayoutConstraint {
22 |
23 | return lhs.constraint(lessThanOrEqualTo: rhs).setup()
24 | }
25 |
26 | @discardableResult
27 | public static func >=(lhs: NSLayoutXAxisAnchor, rhs: NSLayoutXAxisAnchor) -> NSLayoutConstraint {
28 |
29 | return lhs.constraint(greaterThanOrEqualTo: rhs).setup()
30 | }
31 |
32 | @discardableResult
33 | public static func ==(lhs: NSLayoutXAxisAnchor, rhs: AttributedAnchor) -> NSLayoutConstraint {
34 |
35 | return lhs.constraint(equalTo: rhs.anchor, constant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
36 | }
37 |
38 | @discardableResult
39 | public static func <=(lhs: NSLayoutXAxisAnchor, rhs: AttributedAnchor) -> NSLayoutConstraint {
40 |
41 | return lhs.constraint(lessThanOrEqualTo: rhs.anchor, constant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
42 | }
43 |
44 | @discardableResult
45 | public static func >=(lhs: NSLayoutXAxisAnchor, rhs: AttributedAnchor) -> NSLayoutConstraint {
46 |
47 | return lhs.constraint(greaterThanOrEqualTo: rhs.anchor, constant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
48 | }
49 |
50 | public static func +(lhs: NSLayoutXAxisAnchor, rhs: CGFloat) -> AttributedAnchor {
51 |
52 | return AttributedAnchor(anchor: lhs, constant: rhs)
53 | }
54 |
55 |
56 | public static func -(lhs: NSLayoutXAxisAnchor, rhs: CGFloat) -> AttributedAnchor {
57 |
58 | return lhs + -rhs
59 | }
60 | }
61 |
62 | extension NSLayoutXAxisAnchor {
63 |
64 | public static func ~(lhs: NSLayoutXAxisAnchor, rhs: Float) -> AttributedAnchor {
65 |
66 | return lhs ~ UILayoutPriority(rhs)
67 | }
68 |
69 | public static func ~(lhs: NSLayoutXAxisAnchor, rhs: UILayoutPriority) -> AttributedAnchor {
70 |
71 | return AttributedAnchor(anchor: lhs, constant: 0, priority: rhs)
72 | }
73 | }
74 |
75 | extension NSLayoutXAxisAnchor {
76 |
77 | public static prefix func --(lhs: NSLayoutXAxisAnchor) -> AttributedAnchor {
78 |
79 | var anchor = AttributedAnchor(anchor: lhs, constant: 0)
80 | anchor.shouldActivate = false
81 | return anchor
82 | }
83 |
84 | public static prefix func ++(lhs: NSLayoutXAxisAnchor) -> AttributedAnchor {
85 |
86 | var anchor = AttributedAnchor(anchor: lhs, constant: 0)
87 | anchor.shouldActivate = true
88 | return anchor
89 | }
90 | }
91 |
92 |
93 | extension NSLayoutYAxisAnchor {
94 |
95 | @discardableResult
96 | public static func ==(lhs: NSLayoutYAxisAnchor, rhs: NSLayoutYAxisAnchor) -> NSLayoutConstraint {
97 |
98 | return lhs.constraint(equalTo: rhs).setup()
99 | }
100 |
101 | @discardableResult
102 | public static func <=(lhs: NSLayoutYAxisAnchor, rhs: NSLayoutYAxisAnchor) -> NSLayoutConstraint {
103 |
104 | return lhs.constraint(lessThanOrEqualTo: rhs).setup()
105 | }
106 |
107 | @discardableResult
108 | public static func >=(lhs: NSLayoutYAxisAnchor, rhs: NSLayoutYAxisAnchor) -> NSLayoutConstraint {
109 |
110 | return lhs.constraint(greaterThanOrEqualTo: rhs).setup()
111 | }
112 |
113 | @discardableResult
114 | public static func ==(lhs: NSLayoutYAxisAnchor, rhs: AttributedAnchor) -> NSLayoutConstraint {
115 |
116 | return lhs.constraint(equalTo: rhs.anchor, constant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
117 | }
118 |
119 | @discardableResult
120 | public static func <=(lhs: NSLayoutYAxisAnchor, rhs: AttributedAnchor) -> NSLayoutConstraint {
121 |
122 | return lhs.constraint(lessThanOrEqualTo: rhs.anchor, constant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
123 | }
124 |
125 | @discardableResult
126 | public static func >=(lhs: NSLayoutYAxisAnchor, rhs: AttributedAnchor) -> NSLayoutConstraint {
127 |
128 | return lhs.constraint(greaterThanOrEqualTo: rhs.anchor, constant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
129 | }
130 |
131 | public static func +(lhs: NSLayoutYAxisAnchor, rhs: CGFloat) -> AttributedAnchor {
132 |
133 | return AttributedAnchor(anchor: lhs, constant: rhs)
134 | }
135 |
136 | public static func -(lhs: NSLayoutYAxisAnchor, rhs: CGFloat) -> AttributedAnchor {
137 |
138 | return lhs + -rhs
139 | }
140 | }
141 |
142 | extension NSLayoutYAxisAnchor {
143 |
144 | public static func ~(lhs: NSLayoutYAxisAnchor, rhs: Float) -> AttributedAnchor {
145 |
146 | return lhs ~ UILayoutPriority(rhs)
147 | }
148 |
149 | public static func ~(lhs: NSLayoutYAxisAnchor, rhs: UILayoutPriority) -> AttributedAnchor {
150 |
151 | return AttributedAnchor(anchor: lhs, constant: 0, priority: rhs)
152 | }
153 | }
154 |
155 | extension NSLayoutYAxisAnchor {
156 |
157 | public static prefix func --(lhs: NSLayoutYAxisAnchor) -> AttributedAnchor {
158 |
159 | return AttributedAnchor(anchor: lhs, constant: 0, shouldActivate: false)
160 | }
161 |
162 | public static prefix func ++(lhs: NSLayoutYAxisAnchor) -> AttributedAnchor {
163 |
164 | return AttributedAnchor(anchor: lhs, constant: 0, shouldActivate: true)
165 | }
166 | }
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Core/NSLayoutConstraintExtension.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraintExtension.swift
3 | // SimplyLayout
4 | //
5 | // Created by aipeople on 27/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | // ---------------
13 | // MARK: - Setup
14 | // ---------------
15 |
16 | extension NSLayoutConstraint {
17 |
18 | internal func setup(withPriority priority: UILayoutPriority = SimplyLayout.config.defaultPriority, activated: Bool = SimplyLayout.config.defaultActivation) -> NSLayoutConstraint {
19 |
20 | self.priority = priority
21 | self.isActive = activated
22 |
23 | if let view = firstItem as? UIView {
24 |
25 | let skip: Bool
26 | if let superview = view.superview {
27 |
28 | if view == (superview as? UITableViewCell)?.contentView ||
29 | view == (superview as? UITableViewHeaderFooterView)?.contentView ||
30 | view == (superview as? UICollectionViewCell)?.contentView {
31 | skip = true
32 | } else {
33 | skip = false
34 | }
35 | } else {
36 | skip = false
37 | }
38 |
39 | if !skip {
40 | view.translatesAutoresizingMaskIntoConstraints = false
41 | }
42 | }
43 |
44 | if SimplyLayout.postNotificationWhenConstrantCreate {
45 |
46 | let notification = Notification(name: SimplyLayout.constraintCreatedNotification, object: self, userInfo: nil)
47 | NotificationQueue.default.enqueue(notification, postingStyle: .now)
48 | }
49 |
50 | return self
51 | }
52 | }
53 |
54 |
55 | // ---------------
56 | // MARK: - Constants
57 | // ---------------
58 | /*
59 | public extension NSLayoutConstraint {
60 |
61 | // MARK: +
62 | public static func + (lhs: NSLayoutConstraint, rhs: CGFloat) -> NSLayoutConstraint {
63 |
64 | lhs.constant = rhs
65 | return lhs
66 | }
67 |
68 | public static func + (lhs: NSLayoutConstraint, rhs: Double) -> NSLayoutConstraint {
69 |
70 | return lhs + CGFloat(rhs)
71 | }
72 |
73 | public static func + (lhs: NSLayoutConstraint, rhs: Int) -> NSLayoutConstraint {
74 |
75 | return lhs + CGFloat(rhs)
76 | }
77 |
78 | // MARK: -
79 | public static func - (lhs: NSLayoutConstraint, rhs: CGFloat) -> NSLayoutConstraint {
80 |
81 | return lhs + -rhs
82 | }
83 |
84 | public static func - (lhs: NSLayoutConstraint, rhs: Double) -> NSLayoutConstraint {
85 |
86 | return lhs + -rhs
87 | }
88 |
89 | public static func - (lhs: NSLayoutConstraint, rhs: Int) -> NSLayoutConstraint {
90 |
91 | return lhs + -rhs
92 | }
93 |
94 | // MARK: ×
95 | public static func * (lhs: NSLayoutConstraint, rhs: CGFloat) -> NSLayoutConstraint {
96 |
97 | if let firstItem = lhs.firstItem {
98 |
99 | let constraint = NSLayoutConstraint(
100 | item: firstItem,
101 | attribute: lhs.firstAttribute,
102 | relatedBy: lhs.relation,
103 | toItem: lhs.secondItem,
104 | attribute: lhs.secondAttribute,
105 | multiplier: rhs,
106 | constant: lhs.constant
107 | )
108 | constraint.priority = lhs.priority
109 | constraint.isActive = lhs.isActive
110 |
111 | if let view = lhs.ownerView {
112 |
113 | view.removeConstraint(lhs)
114 | view.addConstraint(constraint)
115 | }
116 | return constraint
117 | }
118 | return lhs
119 | }
120 |
121 | public static func * (lhs: NSLayoutConstraint, rhs: Double) -> NSLayoutConstraint {
122 |
123 | return lhs * CGFloat(rhs)
124 | }
125 |
126 | public static func * (lhs: NSLayoutConstraint, rhs: Int) -> NSLayoutConstraint {
127 |
128 | return lhs * CGFloat(rhs)
129 | }
130 | }*/
131 |
132 |
133 | // ---------------
134 | // MARK: - Priority
135 | // ---------------
136 | /*
137 | public extension NSLayoutConstraint {
138 |
139 | @discardableResult
140 | public static func ~ (lhs: NSLayoutConstraint, rhs: UILayoutPriority) -> NSLayoutConstraint {
141 |
142 | if let firstItem = lhs.firstItem {
143 |
144 | let constraint = NSLayoutConstraint(
145 | item: firstItem,
146 | attribute: lhs.firstAttribute,
147 | relatedBy: lhs.relation,
148 | toItem: lhs.secondItem,
149 | attribute: lhs.secondAttribute,
150 | multiplier: lhs.multiplier,
151 | constant: lhs.constant
152 | )
153 | constraint.priority = rhs
154 | constraint.isActive = lhs.isActive
155 |
156 | if let view = lhs.ownerView {
157 |
158 | view.removeConstraint(lhs)
159 | view.addConstraint(constraint)
160 | }
161 | return constraint
162 | }
163 | return lhs
164 | }
165 |
166 | @discardableResult
167 | public static func ~ (lhs: NSLayoutConstraint, rhs: Int) -> NSLayoutConstraint {
168 |
169 | return lhs ~ UILayoutPriority(Float(rhs))
170 | }
171 |
172 | @discardableResult
173 | public static func ~ (lhs: NSLayoutConstraint, rhs: CGFloat) -> NSLayoutConstraint {
174 |
175 | return lhs ~ UILayoutPriority(Float(rhs))
176 | }
177 |
178 | @discardableResult
179 | public static func ~ (lhs: NSLayoutConstraint, rhs: Double) -> NSLayoutConstraint {
180 |
181 | return lhs ~ UILayoutPriority(Float(rhs))
182 | }
183 | }
184 |
185 |
186 | extension NSLayoutConstraint {
187 |
188 | fileprivate var ownerView: UIView? {
189 |
190 | var parentView: UIView? = firstItem as? UIView
191 | while true {
192 | if let view = parentView {
193 | if view.constraints.contains(self) {
194 | break
195 | } else {
196 | parentView = view.superview
197 | }
198 | } else {
199 | break
200 | }
201 | }
202 | return parentView
203 | }
204 | }*/
205 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Core/NSLayoutDimensionExtension.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutDimensionExtension.swift
3 | // SimplyLayout
4 | //
5 | // Created by aipeople on 27/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | extension NSLayoutDimension {
13 |
14 | // MARK: To anchor
15 | @discardableResult
16 | public static func ==(lhs: NSLayoutDimension, rhs: NSLayoutDimension) -> NSLayoutConstraint {
17 |
18 | return lhs.constraint(equalTo: rhs).setup()
19 | }
20 |
21 | @discardableResult
22 | public static func <=(lhs: NSLayoutDimension, rhs: NSLayoutDimension) -> NSLayoutConstraint {
23 |
24 | return lhs.constraint(lessThanOrEqualTo: rhs).setup()
25 | }
26 |
27 | @discardableResult
28 | public static func >=(lhs: NSLayoutDimension, rhs: NSLayoutDimension) -> NSLayoutConstraint {
29 |
30 | return lhs.constraint(greaterThanOrEqualTo: rhs).setup()
31 | }
32 |
33 | // MARK: To mudified dimension
34 | @discardableResult
35 | public static func ==(lhs: NSLayoutDimension, rhs: AttributedDimension) -> NSLayoutConstraint {
36 |
37 | return lhs.constraint(equalTo: rhs.dimension, multiplier: rhs.multiplier, constant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
38 | }
39 |
40 | @discardableResult
41 | public static func <=(lhs: NSLayoutDimension, rhs: AttributedDimension) -> NSLayoutConstraint {
42 |
43 | return lhs.constraint(lessThanOrEqualTo: rhs.dimension, multiplier: rhs.multiplier, constant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
44 | }
45 |
46 | @discardableResult
47 | public static func >=(lhs: NSLayoutDimension, rhs: AttributedDimension) -> NSLayoutConstraint {
48 |
49 | return lhs.constraint(greaterThanOrEqualTo: rhs.dimension, multiplier: rhs.multiplier, constant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
50 | }
51 |
52 | // MARK: To mudified constant
53 | @discardableResult
54 | public static func ==(lhs: NSLayoutDimension, rhs: AttributedConstant) -> NSLayoutConstraint {
55 |
56 | return lhs.constraint(equalToConstant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
57 | }
58 |
59 | @discardableResult
60 | public static func <=(lhs: NSLayoutDimension, rhs: AttributedConstant) -> NSLayoutConstraint {
61 |
62 | return lhs.constraint(lessThanOrEqualToConstant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
63 | }
64 |
65 | @discardableResult
66 | public static func >=(lhs: NSLayoutDimension, rhs: AttributedConstant) -> NSLayoutConstraint {
67 |
68 | return lhs.constraint(greaterThanOrEqualToConstant: rhs.constant).setup(withPriority: rhs.priority, activated: rhs.shouldActivate)
69 | }
70 |
71 | // MARK: To number
72 | @discardableResult
73 | public static func ==(lhs: NSLayoutDimension, rhs: CGFloat) -> NSLayoutConstraint {
74 |
75 | return lhs.constraint(equalToConstant: rhs).setup()
76 | }
77 |
78 | @discardableResult
79 | public static func <=(lhs: NSLayoutDimension, rhs: CGFloat) -> NSLayoutConstraint {
80 |
81 | return lhs.constraint(lessThanOrEqualToConstant: rhs).setup()
82 | }
83 |
84 | @discardableResult
85 | public static func >=(lhs: NSLayoutDimension, rhs: CGFloat) -> NSLayoutConstraint {
86 |
87 | return lhs.constraint(greaterThanOrEqualToConstant: rhs).setup()
88 | }
89 |
90 | // MARK: Constant
91 |
92 | public static func +(lhs: NSLayoutDimension, rhs: CGFloat) -> AttributedDimension {
93 |
94 | return AttributedDimension(dimension: lhs, multiplier: 1, constant: rhs)
95 | }
96 |
97 | public static func -(lhs: NSLayoutDimension, rhs: CGFloat) -> AttributedDimension {
98 |
99 | return lhs + -rhs
100 | }
101 |
102 | // MARK: Multiplier
103 |
104 | public static func *(lhs: NSLayoutDimension, rhs: CGFloat) -> AttributedDimension {
105 |
106 | return AttributedDimension(dimension: lhs, multiplier: rhs, constant: 0)
107 | }
108 | }
109 |
110 |
111 | extension NSLayoutDimension {
112 |
113 | public static func ~(lhs: NSLayoutDimension, rhs: Float) -> AttributedDimension {
114 |
115 | return lhs ~ UILayoutPriority(rhs)
116 | }
117 |
118 | public static func ~(lhs: NSLayoutDimension, rhs: UILayoutPriority) -> AttributedDimension {
119 |
120 | return AttributedDimension(dimension: lhs, multiplier: 1, constant: 0, priority: rhs)
121 | }
122 | }
123 |
124 | extension NSLayoutDimension {
125 |
126 | public static prefix func --(lhs: NSLayoutDimension) -> AttributedDimension {
127 |
128 | return AttributedDimension(dimension: lhs, multiplier: 1, constant: 0)
129 | }
130 |
131 | public static prefix func ++(lhs: NSLayoutDimension) -> AttributedDimension {
132 |
133 | return AttributedDimension(dimension: lhs, multiplier: 1, constant: 0)
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Core/SimplyLayout.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SimplyLayout.swift
3 | // SimplyLayout
4 | //
5 | // Created by aipeople on 28/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | precedencegroup SimplyLayoutPriorityPrecedenceGroup {
13 | higherThan: ComparisonPrecedence
14 | lowerThan: NilCoalescingPrecedence
15 | }
16 |
17 | public class SimplyLayout {
18 |
19 | public static let config = SimplyLayoutConfiguration()
20 | public static var postNotificationWhenConstrantCreate: Bool = false
21 | public static let constraintCreatedNotification = Notification.Name(rawValue: "SimplyLayout.constraintCreatedNotification")
22 | }
23 |
24 |
25 | public class SimplyLayoutConfiguration {
26 |
27 | public var defaultPriority: UILayoutPriority = .required
28 | public var defaultActivation: Bool = true
29 | }
30 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Group/ConstraintGroup.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ConstraintGroup.swift
3 | // SimplyLayout
4 | //
5 | // Created by Sean, Su on 2019/1/1.
6 | // Copyright © 2019 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 |
12 | class ConstraintRecorder {
13 |
14 | static let `default` = ConstraintRecorder()
15 |
16 | fileprivate var createdConstraints: NSHashTable?
17 | fileprivate var postConstraintCreationNotificationByDefault: Bool = false
18 |
19 | init() {
20 |
21 | NotificationCenter.default.addObserver(
22 | forName: SimplyLayout.constraintCreatedNotification, object: nil, queue: nil) {
23 | [weak self] (notification) in
24 |
25 | guard let constraint = notification.object as? NSLayoutConstraint else {
26 | return
27 | }
28 | self?.createdConstraints?.add(constraint)
29 | }
30 | }
31 |
32 | func startRecording() {
33 |
34 | createdConstraints = NSHashTable(options: [.weakMemory], capacity: 1)
35 | postConstraintCreationNotificationByDefault = SimplyLayout.postNotificationWhenConstrantCreate
36 | SimplyLayout.postNotificationWhenConstrantCreate = true
37 | }
38 |
39 | func endRecording() {
40 |
41 | SimplyLayout.postNotificationWhenConstrantCreate = postConstraintCreationNotificationByDefault
42 | createdConstraints = nil
43 | }
44 | }
45 |
46 |
47 | extension Array where Element == NSLayoutConstraint {
48 |
49 | public func activateAll() {
50 | for constraint in self {
51 | constraint.isActive = true
52 | }
53 | }
54 |
55 | public func deactivateAll() {
56 | for constraint in self {
57 | constraint.isActive = false
58 | }
59 | }
60 | }
61 |
62 |
63 | extension NSLayoutConstraint {
64 |
65 | public class func group(activated: Bool = SimplyLayout.config.defaultActivation, _ action: () -> ()) -> [NSLayoutConstraint] {
66 |
67 | assert(Thread.isMainThread, "Constraint group must be created on main thread")
68 |
69 | let originActivation = SimplyLayout.config.defaultActivation
70 |
71 | ConstraintRecorder.default.startRecording()
72 | SimplyLayout.config.defaultActivation = activated
73 | defer {
74 | ConstraintRecorder.default.endRecording()
75 | SimplyLayout.config.defaultActivation = originActivation
76 | }
77 |
78 | action()
79 | return ConstraintRecorder.default.createdConstraints?.allObjects ?? []
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 | NSPrincipalClass
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Sources/SimplyLayout/SimplyLayout.h:
--------------------------------------------------------------------------------
1 | //
2 | // SimplyLayout.h
3 | // SimplyLayout
4 | //
5 | // Created by aipeople on 15/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for SimplyLayout.
12 | FOUNDATION_EXPORT double SimplyLayoutVersionNumber;
13 |
14 | //! Project version string for SimplyLayout.
15 | FOUNDATION_EXPORT const unsigned char SimplyLayoutVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Sources/SimplyLayoutDemo/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // SimplyLayoutDemo
4 | //
5 | // Created by aipeople on 15/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Sources/SimplyLayoutDemo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | }
88 | ],
89 | "info" : {
90 | "version" : 1,
91 | "author" : "xcode"
92 | }
93 | }
--------------------------------------------------------------------------------
/Sources/SimplyLayoutDemo/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Sources/SimplyLayoutDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Sources/SimplyLayoutDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Sources/SimplyLayoutDemo/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // SimplyLayoutDemo
4 | //
5 | // Created by aipeople on 15/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import SimplyLayout
11 |
12 | class ViewController: UIViewController {
13 |
14 | override func viewDidLoad() {
15 |
16 | super.viewDidLoad()
17 |
18 | let background = UIView()
19 | background.backgroundColor = .lightGray
20 |
21 | view.addSubview(background)
22 | background.edgeAnchor == background.superview!.edgeAnchor + UIEdgeInsets(top: 10, left: 20, bottom: 10, right: 20)
23 |
24 |
25 | let boxA = UIView()
26 | let boxB = UIView()
27 | view.addSubview(boxA)
28 | view.addSubview(boxB)
29 |
30 | boxA.backgroundColor = .red
31 | boxB.backgroundColor = .orange
32 |
33 | let verticalConstraintGroup = NSLayoutConstraint.group {
34 |
35 | boxA.centerXAnchor == boxA.superview!.centerXAnchor
36 | boxB.centerXAnchor == boxB.superview!.centerXAnchor
37 |
38 | boxA.heightAnchor == boxB.heightAnchor
39 | boxA.widthAnchor == 40
40 | boxB.widthAnchor == 40
41 |
42 | boxA.topAnchor == boxA.superview!.topAnchor + 10
43 | boxB.topAnchor == boxA.bottomAnchor + 10
44 | boxB.bottomAnchor == boxB.superview!.bottomAnchor - 10
45 | }
46 |
47 | let horizontalConstraintGroup = NSLayoutConstraint.group(activated: false) {
48 |
49 | boxA.centerYAnchor == boxA.superview!.centerYAnchor
50 | boxB.centerYAnchor == boxB.superview!.centerYAnchor
51 |
52 | boxA.widthAnchor == boxB.widthAnchor
53 | boxA.heightAnchor == 40
54 | boxB.heightAnchor == 40
55 |
56 | boxA.leftAnchor == boxA.superview!.leftAnchor + 10
57 | boxB.leftAnchor == boxA.rightAnchor + 10
58 | boxB.rightAnchor == boxB.superview!.rightAnchor - 10
59 | }
60 |
61 |
62 | let box = UIView()
63 | box.backgroundColor = .lightGray
64 | view.addSubview(box)
65 |
66 | // Setup globally configs
67 | // Basically, configs should be set in `didFinishLaunchingWithOptions:`
68 | //SimplyLayout.config.defaultActivation = true // Default value is `true`
69 | //SimplyLayout.config.defaultPriority = .required // Default value is `.required`
70 |
71 | // Setup a constraint with constant by using `+` or `-`
72 | box.widthAnchor == 100 // The constant can be Int, Double, CGFloat
73 |
74 | // Setup a constraint with mutiplier by using `*`
75 | box.heightAnchor == box.superview!.heightAnchor * 0.25 + 40
76 |
77 | // Setup a constraint with priority by using `~`
78 | box.heightAnchor == box.superview!.heightAnchor * 0.25 ~ 750
79 |
80 | // Setup a constraint with activate or inactivate state by using `--` or `++`
81 | box.centerXAnchor == box.superview!.centerXAnchor ~ 750 // The constraint will be activated based on the value of `defaultActivation` in configs.
82 | box.centerXAnchor == --box.superview!.centerXAnchor + 100 // This will force the constraint stays in inactive mode after created.
83 |
84 | // Store the created constraint
85 | let centerYConstraint = box.centerYAnchor == box.superview!.centerYAnchor
86 |
87 | // Modify the stored constraint
88 | DispatchQueue.global().async {
89 | sleep(3)
90 | DispatchQueue.main.async {
91 |
92 | UIView.animate(withDuration: 0.5, animations: {
93 | centerYConstraint.constant = 100
94 | verticalConstraintGroup.deactivateAll()
95 | horizontalConstraintGroup.activateAll()
96 | self.view.layoutIfNeeded()
97 | })
98 | }
99 | }
100 | }
101 |
102 | override func didReceiveMemoryWarning() {
103 | super.didReceiveMemoryWarning()
104 | // Dispose of any resources that can be recreated.
105 | }
106 |
107 |
108 | }
109 |
110 |
--------------------------------------------------------------------------------
/Tests/SimplyLayoutTests/Test.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Test.swift
3 | // SimplyLayout
4 | //
5 | // Created by aipeople on 15/09/2017.
6 | // Copyright © 2017 aipeople. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public class Test {
12 |
13 | init() {
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------