Compare commits

...

37 Commits

Author SHA1 Message Date
14e097a6e8 Commit automatico: Aggiornamento dei file 2023-12-17 10:30:23 +01:00
d55a237e19 Merge pull request #7 from giuseppenucifora/sviluppo
Release 1.0.0
2015-10-29 02:06:56 +01:00
7ae28a6103 Release 1.0.0 2015-10-29 02:05:45 +01:00
793fb1d5d9 Merge pull request #6 from giuseppenucifora/sviluppo
Release 1.0.0
2015-10-29 02:02:59 +01:00
e142b382bc Release 1.0.0 2015-10-29 02:02:02 +01:00
94a61634ef Merge pull request #5 from giuseppenucifora/master
Release 1.0
2015-10-29 01:48:19 +01:00
e3702a16fe Merge pull request #4 from giuseppenucifora/sviluppo
Release 1.0
2015-10-29 01:45:17 +01:00
b577403e80 no message 2015-10-29 01:42:58 +01:00
1d48a97fdc Merge remote-tracking branch 'origin/master'
Conflicts:
	Example/TabBarPicker/TabBarPickerViewController.m
	Pod/Classes/TabBarItem.m
	Pod/Classes/TabBarPicker.m
	Pod/Classes/TabBarPickerSubItemsView.h
	Pod/Classes/TabBarPickerSubItemsView.m
	Pod/Classes/TabBarSubItem.h
	Pod/Classes/TabBarSubItem.m
2015-10-29 01:21:29 +01:00
51f579c3f4 Release 1.0.0 2015-10-29 01:07:28 +01:00
01b55ac158 Merge pull request #3 from giuseppenucifora/sviluppo
Sviluppo
2015-10-29 01:06:18 +01:00
58766efe14 no message 2015-10-29 01:05:34 +01:00
40cdd4eb91 Release 1.0.0 2015-10-29 01:04:32 +01:00
9d5fa8835c no message 2015-08-20 11:56:47 +02:00
3dc7c75b58 - Fix 2015-08-18 18:15:47 +02:00
5ecc0d4203 Merge pull request #2 from giuseppenucifora/sviluppo
Release 0.3.0
2015-08-18 15:39:30 +02:00
ae2f7ac8cd Merge pull request #1 from giuseppenucifora/sviluppo
Upgrade 0.3.0
2015-08-18 15:36:38 +02:00
a2f62db36e Release 0.3.0 2015-08-18 15:35:51 +02:00
7822588918 no message 2015-08-18 15:11:09 +02:00
ab1b14b4e2 - Add Alert block 2015-08-18 15:00:07 +02:00
dfd5420089 - Fix tab touches 2015-08-18 14:48:12 +02:00
4d7c6109a6 no message 2015-08-18 12:17:26 +02:00
6c0f2bbae5 - Upgrade Images
- Fix Vari
2015-08-07 18:41:49 +02:00
091bb39d54 - Fix object 2015-08-07 18:29:24 +02:00
d4dbaff0e7 - Fix Elements in ScrollView 2015-08-07 14:34:01 +02:00
4936fcd2ec - Fix
- upgrade Pods
2015-08-07 12:31:48 +02:00
1797083a99 - Add Show/Hide Animation 2015-07-22 17:43:49 +02:00
f217268512 - Fix autolayout management 2015-07-22 17:24:42 +02:00
7a34b09ccf - Inizio lavoro su animazioni 2015-07-22 16:26:28 +02:00
967bf95336 - Update images
- Implement SubItemsView (NOT COMPLETED)
2015-07-21 15:43:02 +02:00
61604557dd - Fix 2015-07-21 10:44:52 +02:00
603962375e - Fixes 2015-07-21 09:21:33 +02:00
c2be9705ac - Fix Test Project 2015-07-17 10:49:59 +02:00
6fe5a9839c Release 0.1.1 2015-07-16 14:18:12 +02:00
901e013182 Merge branch 'master' of https://github.com/giuseppenucifora/TabBarPicker
Conflicts:
	.gitignore
	LICENSE
2015-07-15 20:16:20 +02:00
c8bd9b7435 Release 0.1.0 2015-07-15 18:26:19 +02:00
01899d7a04 Initial commit 2015-07-15 18:24:58 +02:00
274 changed files with 23170 additions and 74 deletions

4
.gitattributes vendored Normal file
View File

@ -0,0 +1,4 @@
*.framework filter=lfs diff=lfs merge=lfs -text
libavcodec.a filter=lfs diff=lfs merge=lfs -text
GoogleMapsBase filter=lfs diff=lfs merge=lfs -text
GoogleMapsCore filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "checkBox.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "checkBox@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "checkBox@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "checkBoxSelected.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "checkBoxSelected@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "checkBoxSelected@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "location.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "location@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "location@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "location_highlighted.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "location_highlighted@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "location_highlighted@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "location_selected.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "location_selected@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "location_selected@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -1,12 +1,25 @@
source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/CocoaPods/Specs.git'
use_frameworks! use_frameworks!
inhibit_all_warnings!
pod 'PureLayout'
pod 'pop', '~> 1.0'
pod 'UIView-Overlay'
pod 'UIActionSheet-Blocks'
pod 'UIAlertViewBlockExtension'
target 'TabBarPicker_Example', :exclusive => true do target 'TabBarPicker_Example', :exclusive => true do
pod "TabBarPicker", :path => "../" pod "TabBarPicker", :path => "../"
pod 'PureLayout'
pod 'pop', '~> 1.0'
pod 'UIView-Overlay'
pod 'UIActionSheet-Blocks'
pod 'UIAlertViewBlockExtension'
end end
target 'TabBarPicker_Tests', :exclusive => true do target 'TabBarPicker_Tests', :exclusive => true do
pod "TabBarPicker", :path => "../" pod "TabBarPicker", :path => "../"
pod 'FBSnapshotTestCase'
end end

33
Example/Podfile.lock Normal file
View File

@ -0,0 +1,33 @@
PODS:
- pop (1.0.8)
- PureLayout (3.0.1)
- TabBarPicker (0.3.0):
- PureLayout
- UIActionSheet-Blocks
- UIAlertViewBlockExtension
- UIView-Overlay
- UIActionSheet-Blocks (1.0.1)
- UIAlertViewBlockExtension (1.0.1)
- UIView-Overlay (0.1)
DEPENDENCIES:
- pop (~> 1.0)
- PureLayout
- TabBarPicker (from `../`)
- UIActionSheet-Blocks
- UIAlertViewBlockExtension
- UIView-Overlay
EXTERNAL SOURCES:
TabBarPicker:
:path: "../"
SPEC CHECKSUMS:
pop: bb773ae2c791ca2629de13b347e7a8b450fa6a57
PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb
TabBarPicker: 67402456b73594ea28a59fb4fb726c5ef3057090
UIActionSheet-Blocks: a5781709d4c7e1bf81e0498caf187ab0535e5caf
UIAlertViewBlockExtension: b4b0a1e62c94170bacce519a2b16afbc81673714
UIView-Overlay: 95e42e733f6fdcfca523a399ba7907d0ca4570a0
COCOAPODS: 0.39.0

View File

@ -0,0 +1 @@
../../../PureLayout/PureLayout/PureLayout/ALView+PureLayout.h

View File

@ -0,0 +1 @@
../../../PureLayout/PureLayout/PureLayout/NSArray+PureLayout.h

View File

@ -0,0 +1 @@
../../../PureLayout/PureLayout/PureLayout/NSLayoutConstraint+PureLayout.h

View File

@ -0,0 +1 @@
../../../PureLayout/PureLayout/PureLayout/PureLayout+Internal.h

View File

@ -0,0 +1 @@
../../../PureLayout/PureLayout/PureLayout/PureLayout.h

View File

@ -0,0 +1 @@
../../../PureLayout/PureLayout/PureLayout/PureLayoutDefines.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/Vendor/AADatePicker/AADatePicker.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/Vendor/MMCPSScrollView/MMCPSScrollView.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/Vendor/NSString+HexColor/NSString+HexColor.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/Vendor/SharedLocationManager/SharedLocationManager.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/TabBarItem.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/TabBarPicker.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/TabBarPickerSubItemsView.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/TabBarSubItem.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/Vendor/TouchableScrollView/ToucheableScrollView.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/Vendor/UIButton+BackgroundColor/UIButton+BackgroundColor.h

View File

@ -0,0 +1 @@
../../../../../Pod/Classes/Vendor/UIButton+BackgroundColor/UIImage+Color.h

View File

@ -0,0 +1 @@
../../../UIActionSheet-Blocks/UIActionSheet+Blocks.h

View File

@ -0,0 +1 @@
../../../UIAlertViewBlockExtension/AlertViewExamples/UIAlertViewBlockExtension/AlertViewActionDispatcher.h

View File

@ -0,0 +1 @@
../../../UIAlertViewBlockExtension/AlertViewExamples/UIAlertViewBlockExtension/UIAlertView+BlockExtension.h

View File

@ -0,0 +1 @@
../../../UIView-Overlay/UIView+Overlay.h

View File

@ -0,0 +1 @@
../../../pop/pop/WebCore/FloatConversion.h

1
Example/Pods/Headers/Private/pop/POP.h generated Symbolic link
View File

@ -0,0 +1 @@
../../../pop/pop/POP.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAction.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimatableProperty.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimation.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimationEvent.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimationEventInternal.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimationExtras.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimationInternal.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimationPrivate.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimationRuntime.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimationTracer.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimationTracerInternal.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimator.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPAnimatorPrivate.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPBasicAnimation.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPBasicAnimationInternal.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPCGUtils.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPCustomAnimation.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPDecayAnimation.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPDecayAnimationInternal.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPDefines.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPGeometry.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPLayerExtras.h

1
Example/Pods/Headers/Private/pop/POPMath.h generated Symbolic link
View File

@ -0,0 +1 @@
../../../pop/pop/POPMath.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPPropertyAnimation.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPPropertyAnimationInternal.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPSpringAnimation.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPSpringAnimationInternal.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPSpringSolver.h

View File

@ -0,0 +1 @@
../../../pop/pop/POPVector.h

View File

@ -0,0 +1 @@
../../../pop/pop/WebCore/TransformationMatrix.h

View File

@ -0,0 +1 @@
../../../pop/pop/WebCore/UnitBezier.h

View File

@ -0,0 +1,38 @@
{
"name": "TabBarPicker",
"version": "0.3.0",
"summary": "TabBarPicker.",
"homepage": "https://github.com/giuseppenucifora/TabBarPicker",
"license": "MIT",
"authors": {
"Giuseppe Nucifora": "me@giuseppenucifora.com"
},
"source": {
"git": "https://github.com/giuseppenucifora/TabBarPicker.git",
"tag": "0.3.0"
},
"platforms": {
"ios": "8.0"
},
"requires_arc": true,
"source_files": "Pod/Classes/**/*",
"resource_bundles": {
"TabBarPicker": [
"Pod/Assets/*.png"
]
},
"dependencies": {
"PureLayout": [
],
"UIView-Overlay": [
],
"UIActionSheet-Blocks": [
],
"UIAlertViewBlockExtension": [
]
}
}

33
Example/Pods/Manifest.lock generated Normal file
View File

@ -0,0 +1,33 @@
PODS:
- pop (1.0.8)
- PureLayout (3.0.1)
- TabBarPicker (0.3.0):
- PureLayout
- UIActionSheet-Blocks
- UIAlertViewBlockExtension
- UIView-Overlay
- UIActionSheet-Blocks (1.0.1)
- UIAlertViewBlockExtension (1.0.1)
- UIView-Overlay (0.1)
DEPENDENCIES:
- pop (~> 1.0)
- PureLayout
- TabBarPicker (from `../`)
- UIActionSheet-Blocks
- UIAlertViewBlockExtension
- UIView-Overlay
EXTERNAL SOURCES:
TabBarPicker:
:path: "../"
SPEC CHECKSUMS:
pop: bb773ae2c791ca2629de13b347e7a8b450fa6a57
PureLayout: f35f5384c9c4e4479df041dbe33ad7577b71ddfb
TabBarPicker: 67402456b73594ea28a59fb4fb726c5ef3057090
UIActionSheet-Blocks: a5781709d4c7e1bf81e0498caf187ab0535e5caf
UIAlertViewBlockExtension: b4b0a1e62c94170bacce519a2b16afbc81673714
UIView-Overlay: 95e42e733f6fdcfca523a399ba7907d0ca4570a0
COCOAPODS: 0.39.0

2308
Example/Pods/Pods.xcodeproj/project.pbxproj generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F1DAA46C7CBB0FB9B92A7891"
BuildableName = "TabBarPicker.bundle"
BlueprintName = "Pods-TabBarPicker_Example-TabBarPicker-TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F1DAA46C7CBB0FB9B92A7891"
BuildableName = "TabBarPicker.bundle"
BlueprintName = "Pods-TabBarPicker_Example-TabBarPicker-TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FD042F8BAEE7119C1EA51707"
BuildableName = "TabBarPicker.framework"
BlueprintName = "Pods-TabBarPicker_Example-TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "FD042F8BAEE7119C1EA51707"
BuildableName = "TabBarPicker.framework"
BlueprintName = "Pods-TabBarPicker_Example-TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AFD4CD498974811C4E61A02F"
BuildableName = "TabBarPicker.bundle"
BlueprintName = "Pods-TabBarPicker_Tests-TabBarPicker-TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "AFD4CD498974811C4E61A02F"
BuildableName = "TabBarPicker.bundle"
BlueprintName = "Pods-TabBarPicker_Tests-TabBarPicker-TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B372419045A1236C95998EEE"
BuildableName = "TabBarPicker.framework"
BlueprintName = "Pods-TabBarPicker_Tests-TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B372419045A1236C95998EEE"
BuildableName = "TabBarPicker.framework"
BlueprintName = "Pods-TabBarPicker_Tests-TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BD7FB1492BD1E0AE4ACA126CFCD5A5D6"
BuildableName = "TabBarPicker.framework"
BlueprintName = "TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BD7FB1492BD1E0AE4ACA126CFCD5A5D6"
BuildableName = "TabBarPicker.framework"
BlueprintName = "TabBarPicker"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

9
Example/Pods/PureLayout/LICENSE generated Executable file
View File

@ -0,0 +1,9 @@
This code is distributed under the terms and conditions of the MIT license.
Copyright (c) 2014-2015 Tyler Fox
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.

View File

@ -0,0 +1,213 @@
//
// ALView+PureLayout.h
// https://github.com/PureLayout/PureLayout
//
// Copyright (c) 2012 Richard Turton
// Copyright (c) 2013-2015 Tyler Fox
//
// This code is distributed under the terms and conditions of the MIT license.
//
// 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 "PureLayoutDefines.h"
__PL_ASSUME_NONNULL_BEGIN
#pragma mark ALView+PureLayout
/**
A category on UIView/NSView that provides a simple yet powerful interface for creating Auto Layout constraints.
*/
@interface ALView (PureLayout)
#pragma mark Factory & Initializer Methods
/** Creates and returns a new view that does not convert the autoresizing mask into constraints. */
+ (instancetype)newAutoLayoutView;
/** Initializes and returns a new view that does not convert the autoresizing mask into constraints. */
- (instancetype)initForAutoLayout;
/** Configures an existing view to not convert the autoresizing mask into constraints and returns the view. */
- (instancetype)configureForAutoLayout;
#pragma mark Center & Align in Superview
/** Centers the view in its superview. */
- (__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperview;
/** Aligns the view to the same axis of its superview. */
- (NSLayoutConstraint *)autoAlignAxisToSuperviewAxis:(ALAxis)axis;
#if __PureLayout_MinBaseSDK_iOS_8_0
/** Centers the view in its superview's margins. Available in iOS 8.0 and later. */
- (__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperviewMargins;
/** Aligns the view to the corresponding margin axis of its superview. Available in iOS 8.0 and later. */
- (NSLayoutConstraint *)autoAlignAxisToSuperviewMarginAxis:(ALAxis)axis;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#pragma mark Pin Edges to Superview
/** Pins the given edge of the view to the same edge of its superview. */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge;
/** Pins the given edge of the view to the same edge of its superview with an inset. */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge withInset:(CGFloat)inset;
/** Pins the given edge of the view to the same edge of its superview with an inset as a maximum or minimum. */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge withInset:(CGFloat)inset relation:(NSLayoutRelation)relation;
/** Pins the edges of the view to the edges of its superview. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdges;
/** Pins the edges of the view to the edges of its superview with the given edge insets. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets;
/** Pins 3 of the 4 edges of the view to the edges of its superview with the given edge insets, excluding one edge. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets excludingEdge:(ALEdge)edge;
#if __PureLayout_MinBaseSDK_iOS_8_0
/** Pins the given edge of the view to the corresponding margin of its superview. Available in iOS 8.0 and later. */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewMargin:(ALEdge)edge;
/** Pins the given edge of the view to the corresponding margin of its superview as a maximum or minimum. Available in iOS 8.0 and later. */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewMargin:(ALEdge)edge relation:(NSLayoutRelation)relation;
/** Pins the edges of the view to the margins of its superview. Available in iOS 8.0 and later. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMargins;
/** Pins 3 of the 4 edges of the view to the margins of its superview excluding one edge. Available in iOS 8.0 and later. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMarginsExcludingEdge:(ALEdge)edge;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#pragma mark Pin Edges
/** Pins an edge of the view to a given edge of another view. */
- (NSLayoutConstraint *)autoPinEdge:(ALEdge)edge toEdge:(ALEdge)toEdge ofView:(ALView *)otherView;
/** Pins an edge of the view to a given edge of another view with an offset. */
- (NSLayoutConstraint *)autoPinEdge:(ALEdge)edge toEdge:(ALEdge)toEdge ofView:(ALView *)otherView withOffset:(CGFloat)offset;
/** Pins an edge of the view to a given edge of another view with an offset as a maximum or minimum. */
- (NSLayoutConstraint *)autoPinEdge:(ALEdge)edge toEdge:(ALEdge)toEdge ofView:(ALView *)otherView withOffset:(CGFloat)offset relation:(NSLayoutRelation)relation;
#pragma mark Align Axes
/** Aligns an axis of the view to the same axis of another view. */
- (NSLayoutConstraint *)autoAlignAxis:(ALAxis)axis toSameAxisOfView:(ALView *)otherView;
/** Aligns an axis of the view to the same axis of another view with an offset. */
- (NSLayoutConstraint *)autoAlignAxis:(ALAxis)axis toSameAxisOfView:(ALView *)otherView withOffset:(CGFloat)offset;
/** Aligns an axis of the view to the same axis of another view with a multiplier. */
- (NSLayoutConstraint *)autoAlignAxis:(ALAxis)axis toSameAxisOfView:(ALView *)otherView withMultiplier:(CGFloat)multiplier;
#pragma mark Match Dimensions
/** Matches a dimension of the view to a given dimension of another view. */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView;
/** Matches a dimension of the view to a given dimension of another view with an offset. */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView withOffset:(CGFloat)offset;
/** Matches a dimension of the view to a given dimension of another view with an offset as a maximum or minimum. */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView withOffset:(CGFloat)offset relation:(NSLayoutRelation)relation;
/** Matches a dimension of the view to a multiple of a given dimension of another view. */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView withMultiplier:(CGFloat)multiplier;
/** Matches a dimension of the view to a multiple of a given dimension of another view as a maximum or minimum. */
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView withMultiplier:(CGFloat)multiplier relation:(NSLayoutRelation)relation;
#pragma mark Set Dimensions
/** Sets the view to a specific size. */
- (__NSArray_of(NSLayoutConstraint *) *)autoSetDimensionsToSize:(CGSize)size;
/** Sets the given dimension of the view to a specific size. */
- (NSLayoutConstraint *)autoSetDimension:(ALDimension)dimension toSize:(CGFloat)size;
/** Sets the given dimension of the view to a specific size as a maximum or minimum. */
- (NSLayoutConstraint *)autoSetDimension:(ALDimension)dimension toSize:(CGFloat)size relation:(NSLayoutRelation)relation;
#pragma mark Set Content Compression Resistance & Hugging
/** Sets the priority of content compression resistance for an axis.
NOTE: This method must be called from within the block passed into the method +[NSLayoutConstraint autoSetPriority:forConstraints:] */
- (void)autoSetContentCompressionResistancePriorityForAxis:(ALAxis)axis;
/** Sets the priority of content hugging for an axis.
NOTE: This method must be called from within the block passed into the method +[NSLayoutConstraint autoSetPriority:forConstraints:] */
- (void)autoSetContentHuggingPriorityForAxis:(ALAxis)axis;
#pragma mark Constrain Any Attributes
/** Constrains an attribute of the view to a given attribute of another view. */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView;
/** Constrains an attribute of the view to a given attribute of another view with an offset. */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView withOffset:(CGFloat)offset;
/** Constrains an attribute of the view to a given attribute of another view with an offset as a maximum or minimum. */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView withOffset:(CGFloat)offset relation:(NSLayoutRelation)relation;
/** Constrains an attribute of the view to a given attribute of another view with a multiplier. */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView withMultiplier:(CGFloat)multiplier;
/** Constrains an attribute of the view to a given attribute of another view with a multiplier as a maximum or minimum. */
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView withMultiplier:(CGFloat)multiplier relation:(NSLayoutRelation)relation;
#pragma mark Pin to Layout Guides (iOS only)
#if TARGET_OS_IPHONE
/** Pins the top edge of the view to the top layout guide of the given view controller with an inset. Available on iOS only. */
- (NSLayoutConstraint *)autoPinToTopLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset;
/** Pins the top edge of the view to the top layout guide of the given view controller with an inset as a maximum or minimum. Available on iOS only. */
- (NSLayoutConstraint *)autoPinToTopLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset relation:(NSLayoutRelation)relation;
/** Pins the bottom edge of the view to the bottom layout guide of the given view controller with an inset. Available on iOS only. */
- (NSLayoutConstraint *)autoPinToBottomLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset;
/** Pins the bottom edge of the view to the bottom layout guide of the given view controller with an inset as a maximum or minimum. Available on iOS only. */
- (NSLayoutConstraint *)autoPinToBottomLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset relation:(NSLayoutRelation)relation;
#endif /* TARGET_OS_IPHONE */
@end
__PL_ASSUME_NONNULL_END

View File

@ -0,0 +1,848 @@
//
// ALView+PureLayout.m
// https://github.com/PureLayout/PureLayout
//
// Copyright (c) 2012 Richard Turton
// Copyright (c) 2013-2015 Tyler Fox
//
// This code is distributed under the terms and conditions of the MIT license.
//
// 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 "ALView+PureLayout.h"
#import "NSLayoutConstraint+PureLayout.h"
#import "NSArray+PureLayout.h"
#import "PureLayout+Internal.h"
#pragma mark - ALView+PureLayout
@implementation ALView (PureLayout)
#pragma mark Factory & Initializer Methods
/**
Creates and returns a new view that does not convert the autoresizing mask into constraints.
*/
+ (instancetype)newAutoLayoutView
{
ALView *view = [self new];
view.translatesAutoresizingMaskIntoConstraints = NO;
return view;
}
/**
Initializes and returns a new view that does not convert the autoresizing mask into constraints.
*/
- (instancetype)initForAutoLayout
{
self = [self init];
if (self) {
self.translatesAutoresizingMaskIntoConstraints = NO;
}
return self;
}
/**
Configures an existing view to not convert the autoresizing mask into constraints and returns the view.
*/
- (instancetype)configureForAutoLayout
{
self.translatesAutoresizingMaskIntoConstraints = NO;
return self;
}
#pragma mark Center in Superview
/**
Centers the view in its superview.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperview
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoAlignAxisToSuperviewAxis:ALAxisHorizontal]];
[constraints addObject:[self autoAlignAxisToSuperviewAxis:ALAxisVertical]];
return constraints;
}
/**
Aligns the view to the same axis of its superview.
@param axis The axis of this view and of its superview to align.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoAlignAxisToSuperviewAxis:(ALAxis)axis
{
self.translatesAutoresizingMaskIntoConstraints = NO;
ALView *superview = self.superview;
NSAssert(superview, @"View's superview must not be nil.\nView: %@", self);
return [self autoConstrainAttribute:(ALAttribute)axis toAttribute:(ALAttribute)axis ofView:superview];
}
#if __PureLayout_MinBaseSDK_iOS_8_0
/**
Centers the view in its superview, taking into account the layout margins of both the view and its superview.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperviewMargins
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoAlignAxisToSuperviewMarginAxis:ALAxisHorizontal]];
[constraints addObject:[self autoAlignAxisToSuperviewMarginAxis:ALAxisVertical]];
return constraints;
}
/**
Aligns the view to the corresponding margin axis of its superview.
@param axis The axis of this view to align to the corresponding margin axis of its superview.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoAlignAxisToSuperviewMarginAxis:(ALAxis)axis
{
self.translatesAutoresizingMaskIntoConstraints = NO;
ALView *superview = self.superview;
NSAssert(superview, @"View's superview must not be nil.\nView: %@", self);
ALMarginAxis marginAxis = [NSLayoutConstraint al_marginAxisForAxis:axis];
return [self autoConstrainAttribute:(ALAttribute)axis toAttribute:(ALAttribute)marginAxis ofView:superview];
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#pragma mark Pin Edges to Superview
/**
Pins the given edge of the view to the same edge of its superview.
@param edge The edge of this view and its superview to pin.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge
{
return [self autoPinEdgeToSuperviewEdge:edge withInset:0.0];
}
/**
Pins the given edge of the view to the same edge of its superview with an inset.
@param edge The edge of this view and its superview to pin.
@param inset The amount to inset this view's edge from the superview's edge.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge withInset:(CGFloat)inset
{
return [self autoPinEdgeToSuperviewEdge:edge withInset:inset relation:NSLayoutRelationEqual];
}
/**
Pins the given edge of the view to the same edge of its superview with an inset as a maximum or minimum.
@param edge The edge of this view and its superview to pin.
@param inset The amount to inset this view's edge from the superview's edge.
@param relation Whether the inset should be at least, at most, or exactly equal to the given value.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge withInset:(CGFloat)inset relation:(NSLayoutRelation)relation
{
self.translatesAutoresizingMaskIntoConstraints = NO;
ALView *superview = self.superview;
NSAssert(superview, @"View's superview must not be nil.\nView: %@", self);
if (edge == ALEdgeBottom || edge == ALEdgeRight || edge == ALEdgeTrailing) {
// The bottom, right, and trailing insets (and relations, if an inequality) are inverted to become offsets
inset = -inset;
if (relation == NSLayoutRelationLessThanOrEqual) {
relation = NSLayoutRelationGreaterThanOrEqual;
} else if (relation == NSLayoutRelationGreaterThanOrEqual) {
relation = NSLayoutRelationLessThanOrEqual;
}
}
return [self autoPinEdge:edge toEdge:edge ofView:superview withOffset:inset relation:relation];
}
/**
Pins the edges of the view to the edges of its superview.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdges
{
return [self autoPinEdgesToSuperviewEdgesWithInsets:ALEdgeInsetsZero];
}
/**
Pins the edges of the view to the edges of its superview with the given edge insets.
The insets.left corresponds to a leading edge constraint, and insets.right corresponds to a trailing edge constraint.
@param insets The insets for this view's edges from its superview's edges.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:insets.top]];
[constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:insets.left]];
[constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:insets.bottom]];
[constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:insets.right]];
return constraints;
}
/**
Pins 3 of the 4 edges of the view to the edges of its superview with the given edge insets, excluding one edge.
The insets.left corresponds to a leading edge constraint, and insets.right corresponds to a trailing edge constraint.
@param insets The insets for this view's edges from its superview's edges. The inset corresponding to the excluded edge
will be ignored.
@param edge The edge of this view to exclude in pinning to its superview; this method will not apply any constraint to it.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets excludingEdge:(ALEdge)edge
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
if (edge != ALEdgeTop) {
[constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:insets.top]];
}
if (edge != ALEdgeLeading && edge != ALEdgeLeft) {
[constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:insets.left]];
}
if (edge != ALEdgeBottom) {
[constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:insets.bottom]];
}
if (edge != ALEdgeTrailing && edge != ALEdgeRight) {
[constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:insets.right]];
}
return constraints;
}
#if __PureLayout_MinBaseSDK_iOS_8_0
/**
Pins the given edge of the view to the corresponding margin of its superview.
@param edge The edge of this view to pin to the corresponding margin of its superview.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinEdgeToSuperviewMargin:(ALEdge)edge
{
return [self autoPinEdgeToSuperviewMargin:edge relation:NSLayoutRelationEqual];
}
/**
Pins the given edge of the view to the corresponding margin of its superview as a maximum or minimum.
@param edge The edge of this view to pin to the corresponding margin of its superview.
@param relation Whether the edge should be inset by at least, at most, or exactly the superview's margin.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinEdgeToSuperviewMargin:(ALEdge)edge relation:(NSLayoutRelation)relation
{
self.translatesAutoresizingMaskIntoConstraints = NO;
ALView *superview = self.superview;
NSAssert(superview, @"View's superview must not be nil.\nView: %@", self);
if (edge == ALEdgeBottom || edge == ALEdgeRight || edge == ALEdgeTrailing) {
// The bottom, right, and trailing relations are inverted
if (relation == NSLayoutRelationLessThanOrEqual) {
relation = NSLayoutRelationGreaterThanOrEqual;
} else if (relation == NSLayoutRelationGreaterThanOrEqual) {
relation = NSLayoutRelationLessThanOrEqual;
}
}
ALMargin margin = [NSLayoutConstraint al_marginForEdge:edge];
return [self autoConstrainAttribute:(ALAttribute)edge toAttribute:(ALAttribute)margin ofView:superview withOffset:0.0 relation:relation];
}
/**
Pins the edges of the view to the margins of its superview.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMargins
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeTop]];
[constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeLeading]];
[constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeBottom]];
[constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeTrailing]];
return constraints;
}
/**
Pins 3 of the 4 edges of the view to the margins of its superview, excluding one edge.
@param edge The edge of this view to exclude in pinning to its superview; this method will not apply any constraint to it.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMarginsExcludingEdge:(ALEdge)edge
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
if (edge != ALEdgeTop) {
[constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeTop]];
}
if (edge != ALEdgeLeading && edge != ALEdgeLeft) {
[constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeLeading]];
}
if (edge != ALEdgeBottom) {
[constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeBottom]];
}
if (edge != ALEdgeTrailing && edge != ALEdgeRight) {
[constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeTrailing]];
}
return constraints;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#pragma mark Pin Edges
/**
Pins an edge of the view to a given edge of another view.
@param edge The edge of this view to pin.
@param toEdge The edge of the other view to pin to.
@param otherView The other view to pin to. Must be in the same view hierarchy as this view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinEdge:(ALEdge)edge toEdge:(ALEdge)toEdge ofView:(ALView *)otherView
{
return [self autoPinEdge:edge toEdge:toEdge ofView:otherView withOffset:0.0];
}
/**
Pins an edge of the view to a given edge of another view with an offset.
@param edge The edge of this view to pin.
@param toEdge The edge of the other view to pin to.
@param otherView The other view to pin to. Must be in the same view hierarchy as this view.
@param offset The offset between the edge of this view and the edge of the other view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinEdge:(ALEdge)edge toEdge:(ALEdge)toEdge ofView:(ALView *)otherView withOffset:(CGFloat)offset
{
return [self autoPinEdge:edge toEdge:toEdge ofView:otherView withOffset:offset relation:NSLayoutRelationEqual];
}
/**
Pins an edge of the view to a given edge of another view with an offset as a maximum or minimum.
@param edge The edge of this view to pin.
@param toEdge The edge of the other view to pin to.
@param otherView The other view to pin to. Must be in the same view hierarchy as this view.
@param offset The offset between the edge of this view and the edge of the other view.
@param relation Whether the offset should be at least, at most, or exactly equal to the given value.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinEdge:(ALEdge)edge toEdge:(ALEdge)toEdge ofView:(ALView *)otherView withOffset:(CGFloat)offset relation:(NSLayoutRelation)relation
{
return [self autoConstrainAttribute:(ALAttribute)edge toAttribute:(ALAttribute)toEdge ofView:otherView withOffset:offset relation:relation];
}
#pragma mark Align Axes
/**
Aligns an axis of the view to the same axis of another view.
@param axis The axis of this view and the other view to align.
@param otherView The other view to align to. Must be in the same view hierarchy as this view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoAlignAxis:(ALAxis)axis toSameAxisOfView:(ALView *)otherView
{
return [self autoAlignAxis:axis toSameAxisOfView:otherView withOffset:0.0];
}
/**
Aligns an axis of the view to the same axis of another view with an offset.
@param axis The axis of this view and the other view to align.
@param otherView The other view to align to. Must be in the same view hierarchy as this view.
@param offset The offset between the axis of this view and the axis of the other view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoAlignAxis:(ALAxis)axis toSameAxisOfView:(ALView *)otherView withOffset:(CGFloat)offset
{
return [self autoConstrainAttribute:(ALAttribute)axis toAttribute:(ALAttribute)axis ofView:otherView withOffset:offset];
}
/**
Aligns an axis of the view to the same axis of another view with a multiplier.
@param axis The axis of this view and the other view to align.
@param otherView The other view to align to. Must be in the same view hierarchy as this view.
@param multiplier The multiplier between the axis of this view and the axis of the other view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoAlignAxis:(ALAxis)axis toSameAxisOfView:(ALView *)otherView withMultiplier:(CGFloat)multiplier
{
return [self autoConstrainAttribute:(ALAttribute)axis toAttribute:(ALAttribute)axis ofView:otherView withMultiplier:multiplier];
}
#pragma mark Match Dimensions
/**
Matches a dimension of the view to a given dimension of another view.
@param dimension The dimension of this view to pin.
@param toDimension The dimension of the other view to pin to.
@param otherView The other view to match to. Must be in the same view hierarchy as this view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView
{
return [self autoMatchDimension:dimension toDimension:toDimension ofView:otherView withOffset:0.0];
}
/**
Matches a dimension of the view to a given dimension of another view with an offset.
@param dimension The dimension of this view to pin.
@param toDimension The dimension of the other view to pin to.
@param otherView The other view to match to. Must be in the same view hierarchy as this view.
@param offset The offset between the dimension of this view and the dimension of the other view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView withOffset:(CGFloat)offset
{
return [self autoMatchDimension:dimension toDimension:toDimension ofView:otherView withOffset:offset relation:NSLayoutRelationEqual];
}
/**
Matches a dimension of the view to a given dimension of another view with an offset as a maximum or minimum.
@param dimension The dimension of this view to pin.
@param toDimension The dimension of the other view to pin to.
@param otherView The other view to match to. Must be in the same view hierarchy as this view.
@param offset The offset between the dimension of this view and the dimension of the other view.
@param relation Whether the offset should be at least, at most, or exactly equal to the given value.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView withOffset:(CGFloat)offset relation:(NSLayoutRelation)relation
{
return [self autoConstrainAttribute:(ALAttribute)dimension toAttribute:(ALAttribute)toDimension ofView:otherView withOffset:offset relation:relation];
}
/**
Matches a dimension of the view to a multiple of a given dimension of another view.
@param dimension The dimension of this view to pin.
@param toDimension The dimension of the other view to pin to.
@param otherView The other view to match to. Must be in the same view hierarchy as this view.
@param multiplier The multiple of the other view's given dimension that this view's given dimension should be.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView withMultiplier:(CGFloat)multiplier
{
return [self autoMatchDimension:dimension toDimension:toDimension ofView:otherView withMultiplier:multiplier relation:NSLayoutRelationEqual];
}
/**
Matches a dimension of the view to a multiple of a given dimension of another view as a maximum or minimum.
@param dimension The dimension of this view to pin.
@param toDimension The dimension of the other view to pin to.
@param otherView The other view to match to. Must be in the same view hierarchy as this view.
@param multiplier The multiple of the other view's given dimension that this view's given dimension should be.
@param relation Whether the multiple should be at least, at most, or exactly equal to the given value.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoMatchDimension:(ALDimension)dimension toDimension:(ALDimension)toDimension ofView:(ALView *)otherView withMultiplier:(CGFloat)multiplier relation:(NSLayoutRelation)relation
{
return [self autoConstrainAttribute:(ALAttribute)dimension toAttribute:(ALAttribute)toDimension ofView:otherView withMultiplier:multiplier relation:relation];
}
#pragma mark Set Dimensions
/**
Sets the view to a specific size.
@param size The size to set this view's dimensions to.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoSetDimensionsToSize:(CGSize)size
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoSetDimension:ALDimensionWidth toSize:size.width]];
[constraints addObject:[self autoSetDimension:ALDimensionHeight toSize:size.height]];
return constraints;
}
/**
Sets the given dimension of the view to a specific size.
@param dimension The dimension of this view to set.
@param size The size to set the given dimension to.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoSetDimension:(ALDimension)dimension toSize:(CGFloat)size
{
return [self autoSetDimension:dimension toSize:size relation:NSLayoutRelationEqual];
}
/**
Sets the given dimension of the view to a specific size as a maximum or minimum.
@param dimension The dimension of this view to set.
@param size The size to set the given dimension to.
@param relation Whether the size should be at least, at most, or exactly equal to the given value.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoSetDimension:(ALDimension)dimension toSize:(CGFloat)size relation:(NSLayoutRelation)relation
{
self.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutAttribute layoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:(ALAttribute)dimension];
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:layoutAttribute relatedBy:relation toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:size];
[constraint autoInstall];
return constraint;
}
#pragma mark Set Content Compression Resistance & Hugging
/**
Sets the priority of content compression resistance for an axis.
NOTE: This method must be called from within the block passed into the method +[autoSetPriority:forConstraints:]
@param axis The axis to set the content compression resistance priority for.
*/
- (void)autoSetContentCompressionResistancePriorityForAxis:(ALAxis)axis
{
NSAssert([NSLayoutConstraint al_isExecutingPriorityConstraintsBlock], @"%@ should only be called from within the block passed into the method +[autoSetPriority:forConstraints:]", NSStringFromSelector(_cmd));
if ([NSLayoutConstraint al_isExecutingPriorityConstraintsBlock]) {
self.translatesAutoresizingMaskIntoConstraints = NO;
ALLayoutConstraintAxis constraintAxis = [NSLayoutConstraint al_constraintAxisForAxis:axis];
#if TARGET_OS_IPHONE
[self setContentCompressionResistancePriority:[NSLayoutConstraint al_currentGlobalConstraintPriority] forAxis:constraintAxis];
#else
[self setContentCompressionResistancePriority:[NSLayoutConstraint al_currentGlobalConstraintPriority] forOrientation:constraintAxis];
#endif /* TARGET_OS_IPHONE */
}
}
/**
Sets the priority of content hugging for an axis.
NOTE: This method must be called from within the block passed into the method +[autoSetPriority:forConstraints:]
@param axis The axis to set the content hugging priority for.
*/
- (void)autoSetContentHuggingPriorityForAxis:(ALAxis)axis
{
NSAssert([NSLayoutConstraint al_isExecutingPriorityConstraintsBlock], @"%@ should only be called from within the block passed into the method +[autoSetPriority:forConstraints:]", NSStringFromSelector(_cmd));
if ([NSLayoutConstraint al_isExecutingPriorityConstraintsBlock]) {
self.translatesAutoresizingMaskIntoConstraints = NO;
ALLayoutConstraintAxis constraintAxis = [NSLayoutConstraint al_constraintAxisForAxis:axis];
#if TARGET_OS_IPHONE
[self setContentHuggingPriority:[NSLayoutConstraint al_currentGlobalConstraintPriority] forAxis:constraintAxis];
#else
[self setContentHuggingPriority:[NSLayoutConstraint al_currentGlobalConstraintPriority] forOrientation:constraintAxis];
#endif /* TARGET_OS_IPHONE */
}
}
#pragma mark Constrain Any Attributes
/**
Constrains an attribute of the view to a given attribute of another view.
This method can be used to constrain different types of attributes across two views.
@param attribute Any attribute of this view to constrain.
@param toAttribute Any attribute of the other view to constrain to.
@param otherView The other view to constrain to. Must be in the same view hierarchy as this view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView
{
return [self autoConstrainAttribute:attribute toAttribute:toAttribute ofView:otherView withOffset:0.0];
}
/**
Constrains an attribute of the view to a given attribute of another view with an offset.
This method can be used to constrain different types of attributes across two views.
@param attribute Any attribute of this view to constrain.
@param toAttribute Any attribute of the other view to constrain to.
@param otherView The other view to constrain to. Must be in the same view hierarchy as this view.
@param offset The offset between the attribute of this view and the attribute of the other view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView withOffset:(CGFloat)offset
{
return [self autoConstrainAttribute:attribute toAttribute:toAttribute ofView:otherView withOffset:offset relation:NSLayoutRelationEqual];
}
/**
Constrains an attribute of the view to a given attribute of another view with an offset as a maximum or minimum.
This method can be used to constrain different types of attributes across two views.
@param attribute Any attribute of this view to constrain.
@param toAttribute Any attribute of the other view to constrain to.
@param otherView The other view to constrain to. Must be in the same view hierarchy as this view.
@param offset The offset between the attribute of this view and the attribute of the other view.
@param relation Whether the offset should be at least, at most, or exactly equal to the given value.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView withOffset:(CGFloat)offset relation:(NSLayoutRelation)relation
{
self.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutAttribute layoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:attribute];
NSLayoutAttribute toLayoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:toAttribute];
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:layoutAttribute relatedBy:relation toItem:otherView attribute:toLayoutAttribute multiplier:1.0 constant:offset];
[constraint autoInstall];
return constraint;
}
/**
Constrains an attribute of the view to a given attribute of another view with a multiplier.
This method can be used to constrain different types of attributes across two views.
@param attribute Any attribute of this view to constrain.
@param toAttribute Any attribute of the other view to constrain to.
@param otherView The other view to constrain to. Must be in the same view hierarchy as this view.
@param multiplier The multiplier between the attribute of this view and the attribute of the other view.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView withMultiplier:(CGFloat)multiplier
{
return [self autoConstrainAttribute:attribute toAttribute:toAttribute ofView:otherView withMultiplier:multiplier relation:NSLayoutRelationEqual];
}
/**
Constrains an attribute of the view to a given attribute of another view with a multiplier as a maximum or minimum.
This method can be used to constrain different types of attributes across two views.
@param attribute Any attribute of this view to constrain.
@param toAttribute Any attribute of the other view to constrain to.
@param otherView The other view to constrain to. Must be in the same view hierarchy as this view.
@param multiplier The multiplier between the attribute of this view and the attribute of the other view.
@param relation Whether the multiplier should be at least, at most, or exactly equal to the given value.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoConstrainAttribute:(ALAttribute)attribute toAttribute:(ALAttribute)toAttribute ofView:(ALView *)otherView withMultiplier:(CGFloat)multiplier relation:(NSLayoutRelation)relation
{
self.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutAttribute layoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:attribute];
NSLayoutAttribute toLayoutAttribute = [NSLayoutConstraint al_layoutAttributeForAttribute:toAttribute];
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:layoutAttribute relatedBy:relation toItem:otherView attribute:toLayoutAttribute multiplier:multiplier constant:0.0];
[constraint autoInstall];
return constraint;
}
#pragma mark Pin to Layout Guides
#if TARGET_OS_IPHONE
/**
Pins the top edge of the view to the top layout guide of the given view controller with an inset.
For compatibility with iOS 6 (where layout guides do not exist), this method will simply pin the top edge of
the view to the top edge of the given view controller's view with an inset.
@param viewController The view controller whose topLayoutGuide should be used to pin to.
@param inset The amount to inset this view's top edge from the layout guide.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinToTopLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset
{
return [self autoPinToTopLayoutGuideOfViewController:viewController withInset:inset relation:NSLayoutRelationEqual];
}
- (NSLayoutConstraint *)autoPinToTopLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset relation:(NSLayoutRelation)relation
{
if (__PureLayout_MinSysVer_iOS_7_0) {
self.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:relation toItem:viewController.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:inset];
[viewController.view al_addConstraint:constraint]; // Can't use autoInstall because the layout guide is not a view
return constraint;
} else {
// iOS 6 fallback
return [self autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:viewController.view withOffset:inset relation:relation];
}
}
/**
Pins the bottom edge of the view to the bottom layout guide of the given view controller with an inset.
For compatibility with iOS 6 (where layout guides do not exist), this method will simply pin the bottom edge of
the view to the bottom edge of the given view controller's view with an inset.
@param viewController The view controller whose bottomLayoutGuide should be used to pin to.
@param inset The amount to inset this view's bottom edge from the layout guide.
@return The constraint added.
*/
- (NSLayoutConstraint *)autoPinToBottomLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset
{
return [self autoPinToBottomLayoutGuideOfViewController:viewController withInset:inset relation:NSLayoutRelationEqual];
}
- (NSLayoutConstraint *)autoPinToBottomLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset relation:(NSLayoutRelation)relation
{
// The bottom inset (and relation, if an inequality) is inverted to become an offset
inset = -inset;
if (relation == NSLayoutRelationLessThanOrEqual) {
relation = NSLayoutRelationGreaterThanOrEqual;
} else if (relation == NSLayoutRelationGreaterThanOrEqual) {
relation = NSLayoutRelationLessThanOrEqual;
}
if (__PureLayout_MinSysVer_iOS_7_0) {
self.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom relatedBy:relation toItem:viewController.bottomLayoutGuide attribute:NSLayoutAttributeTop multiplier:1.0 constant:inset];
[viewController.view al_addConstraint:constraint]; // Can't use autoInstall because the layout guide is not a view
return constraint;
} else {
// iOS 6 fallback
return [self autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:viewController.view withOffset:inset relation:relation];
}
}
#endif /* TARGET_OS_IPHONE */
#pragma mark Internal Methods
/**
Adds the given constraint to this view after applying the global state to the constraint.
NOTE: This method is compatible with all versions of iOS, and should be used for older versions before the active
property on NSLayoutConstraint was introduced.
This method should be the only one that calls the UIView/NSView addConstraint: method directly.
@param constraint The constraint to set the global priority on and then add to this view.
*/
- (void)al_addConstraint:(NSLayoutConstraint *)constraint
{
[NSLayoutConstraint al_applyGlobalStateToConstraint:constraint];
if ([NSLayoutConstraint al_preventAutomaticConstraintInstallation]) {
[[NSLayoutConstraint al_currentArrayOfCreatedConstraints] addObject:constraint];
} else {
[self addConstraint:constraint];
}
}
/**
Returns the common superview for this view and the given other view.
Raises an exception if this view and the other view do not share a common superview.
@return The common superview for the two views.
*/
- (ALView *)al_commonSuperviewWithView:(ALView *)otherView
{
ALView *commonSuperview = nil;
ALView *startView = self;
do {
#if TARGET_OS_IPHONE
if ([otherView isDescendantOfView:startView]) {
commonSuperview = startView;
}
#else
if ([otherView isDescendantOf:startView]) {
commonSuperview = startView;
}
#endif /* TARGET_OS_IPHONE */
startView = startView.superview;
} while (startView && !commonSuperview);
NSAssert(commonSuperview, @"Can't constrain two views that do not share a common superview. Make sure that both views have been added into the same view hierarchy.");
return commonSuperview;
}
/**
Aligns this view to another view with an alignment attribute.
@param attribute The attribute to use to align the two views.
@param otherView The other view to align to.
@param axis The axis along which the views are distributed, used to validate the alignment attribute.
@return The constraint added.
*/
- (NSLayoutConstraint *)al_alignAttribute:(ALAttribute)attribute toView:(ALView *)otherView forAxis:(ALAxis)axis
{
NSLayoutConstraint *constraint = nil;
switch (attribute) {
case ALAttributeVertical:
NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with ALAttributeVertical.");
constraint = [self autoAlignAxis:ALAxisVertical toSameAxisOfView:otherView];
break;
case ALAttributeHorizontal:
NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with ALAttributeHorizontal.");
constraint = [self autoAlignAxis:ALAxisHorizontal toSameAxisOfView:otherView];
break;
case ALAttributeBaseline: // same value as ALAttributeLastBaseline
NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with ALAttributeBaseline.");
constraint = [self autoAlignAxis:ALAxisBaseline toSameAxisOfView:otherView];
break;
#if __PureLayout_MinBaseSDK_iOS_8_0
case ALAttributeFirstBaseline:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALAttributeFirstBaseline is only supported on iOS 8.0 or higher.");
NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with ALAttributeFirstBaseline.");
constraint = [self autoAlignAxis:ALAxisFirstBaseline toSameAxisOfView:otherView];
break;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
case ALAttributeTop:
NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with ALAttributeTop.");
constraint = [self autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:otherView];
break;
case ALAttributeLeft:
NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with ALAttributeLeft.");
constraint = [self autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:otherView];
break;
case ALAttributeBottom:
NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with ALAttributeBottom.");
constraint = [self autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:otherView];
break;
case ALAttributeRight:
NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with ALAttributeRight.");
constraint = [self autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:otherView];
break;
case ALAttributeLeading:
NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with ALAttributeLeading.");
constraint = [self autoPinEdge:ALEdgeLeading toEdge:ALEdgeLeading ofView:otherView];
break;
case ALAttributeTrailing:
NSAssert(axis == ALAxisVertical, @"Cannot align views that are distributed horizontally with ALAttributeTrailing.");
constraint = [self autoPinEdge:ALEdgeTrailing toEdge:ALEdgeTrailing ofView:otherView];
break;
// All of the below attributes are invalid as alignment options. Listing them explicitly (even though they just fall through to the default case) to avoid an incomplete switch statement warning from the compiler.
case ALAttributeWidth:
case ALAttributeHeight:
#if __PureLayout_MinBaseSDK_iOS_8_0
case ALAttributeMarginLeft:
case ALAttributeMarginRight:
case ALAttributeMarginTop:
case ALAttributeMarginBottom:
case ALAttributeMarginLeading:
case ALAttributeMarginTrailing:
case ALAttributeMarginAxisVertical:
case ALAttributeMarginAxisHorizontal:
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
default:
NSAssert(nil, @"Unsupported attribute for alignment.");
break;
}
return constraint;
}
@end

View File

@ -0,0 +1,115 @@
//
// NSArray+PureLayout.h
// https://github.com/PureLayout/PureLayout
//
// Copyright (c) 2012 Richard Turton
// Copyright (c) 2013-2015 Tyler Fox
//
// This code is distributed under the terms and conditions of the MIT license.
//
// 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 "PureLayoutDefines.h"
__PL_ASSUME_NONNULL_BEGIN
#pragma mark NSArray+PureLayout
/**
A category on NSArray that provides a simple yet powerful interface to:
- Manage an array of Auto Layout constraints
- Apply constraints to an array of views
*/
@interface NSArray (PureLayout)
#pragma mark Array of Constraints
/** Activates the constraints in this array. */
- (void)autoInstallConstraints;
/** Deactivates the constraints in this array. */
- (void)autoRemoveConstraints;
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
/** Sets the string as the identifier for the constraints in this array. Available in iOS 7.0 and OS X 10.9 and later. */
- (instancetype)autoIdentifyConstraints:(NSString *)identifier;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#pragma mark Array of Views
/** Aligns views in this array to one another along a given edge. */
- (__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToEdge:(ALEdge)edge;
/** Aligns views in this array to one another along a given axis. */
- (__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToAxis:(ALAxis)axis;
/** Matches a given dimension of all the views in this array. */
- (__NSArray_of(NSLayoutConstraint *) *)autoMatchViewsDimension:(ALDimension)dimension;
/** Sets the given dimension of all the views in this array to a given size. */
- (__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimension:(ALDimension)dimension toSize:(CGFloat)size;
/** Sets all of the views in this array to a given size. */
- (__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimensionsToSize:(CGSize)size;
/** Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (variable) in the dimension along the axis and will have spacing (fixed) between them. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing;
/** Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (variable) in the dimension along the axis and will have spacing (fixed) between them, with optional insets from the first and last views to their superview. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
insetSpacing:(BOOL)shouldSpaceInsets;
/** Distributes the views in this array equally along the selected axis in their superview.
Views will have spacing (fixed) between them, with optional insets from the first and last views to their superview, and optionally constrained to the same size in the dimension along the axis. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
insetSpacing:(BOOL)shouldSpaceInsets
matchedSizes:(BOOL)shouldMatchSizes;
/** Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (fixed) in the dimension along the axis and will have spacing (variable) between them. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSize:(CGFloat)size;
/** Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (fixed) in the dimension along the axis and will have spacing (variable) between them, with optional insets from the first and last views to their superview. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSize:(CGFloat)size
insetSpacing:(BOOL)shouldSpaceInsets;
@end
__PL_ASSUME_NONNULL_END

View File

@ -0,0 +1,505 @@
//
// NSArray+PureLayout.m
// https://github.com/PureLayout/PureLayout
//
// Copyright (c) 2012 Richard Turton
// Copyright (c) 2013-2015 Tyler Fox
//
// This code is distributed under the terms and conditions of the MIT license.
//
// 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 "NSArray+PureLayout.h"
#import "ALView+PureLayout.h"
#import "NSLayoutConstraint+PureLayout.h"
#import "PureLayout+Internal.h"
#pragma mark - NSArray+PureLayout
@implementation NSArray (PureLayout)
#pragma mark Array of Constraints
/**
Activates the constraints in this array.
*/
- (void)autoInstallConstraints
{
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
if ([NSLayoutConstraint respondsToSelector:@selector(activateConstraints:)]) {
for (id object in self) {
if ([object isKindOfClass:[NSLayoutConstraint class]]) {
[NSLayoutConstraint al_applyGlobalStateToConstraint:object];
}
}
if ([NSLayoutConstraint al_preventAutomaticConstraintInstallation]) {
[[NSLayoutConstraint al_currentArrayOfCreatedConstraints] addObjectsFromArray:self];
} else {
[NSLayoutConstraint activateConstraints:self];
}
return;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
for (id object in self) {
if ([object isKindOfClass:[NSLayoutConstraint class]]) {
[((NSLayoutConstraint *)object) autoInstall];
}
}
}
/**
Deactivates the constraints in this array.
*/
- (void)autoRemoveConstraints
{
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
if ([NSLayoutConstraint respondsToSelector:@selector(deactivateConstraints:)]) {
[NSLayoutConstraint deactivateConstraints:self];
return;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
for (id object in self) {
if ([object isKindOfClass:[NSLayoutConstraint class]]) {
[((NSLayoutConstraint *)object) autoRemove];
}
}
}
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
/**
Sets the string as the identifier for the constraints in this array. Available in iOS 7.0 and OS X 10.9 and later.
The identifier will be printed along with each constraint's description.
This is helpful to document the constraints' purpose and aid in debugging.
@param identifier A string used to identify the constraints in this array.
@return This array.
*/
- (instancetype)autoIdentifyConstraints:(NSString *)identifier
{
for (id object in self) {
if ([object isKindOfClass:[NSLayoutConstraint class]]) {
[((NSLayoutConstraint *)object) autoIdentify:identifier];
}
}
return self;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#pragma mark Array of Views
/**
Aligns views in this array to one another along a given edge.
Note: This array must contain at least 2 views, and all views must share a common superview.
@param edge The edge to which the views will be aligned.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToEdge:(ALEdge)edge
{
NSAssert([self al_containsMinimumNumberOfViews:2], @"This array must contain at least 2 views.");
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
ALView *previousView = nil;
for (id object in self) {
if ([object isKindOfClass:[ALView class]]) {
ALView *view = (ALView *)object;
view.translatesAutoresizingMaskIntoConstraints = NO;
if (previousView) {
[constraints addObject:[view autoPinEdge:edge toEdge:edge ofView:previousView]];
}
previousView = view;
}
}
return constraints;
}
/**
Aligns views in this array to one another along a given axis.
Note: This array must contain at least 2 views, and all views must share a common superview.
@param axis The axis to which the views will be aligned.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToAxis:(ALAxis)axis
{
NSAssert([self al_containsMinimumNumberOfViews:2], @"This array must contain at least 2 views.");
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
ALView *previousView = nil;
for (id object in self) {
if ([object isKindOfClass:[ALView class]]) {
ALView *view = (ALView *)object;
view.translatesAutoresizingMaskIntoConstraints = NO;
if (previousView) {
[constraints addObject:[view autoAlignAxis:axis toSameAxisOfView:previousView]];
}
previousView = view;
}
}
return constraints;
}
/**
Matches a given dimension of all the views in this array.
Note: This array must contain at least 2 views, and all views must share a common superview.
@param dimension The dimension to match for all of the views.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoMatchViewsDimension:(ALDimension)dimension
{
NSAssert([self al_containsMinimumNumberOfViews:2], @"This array must contain at least 2 views.");
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
ALView *previousView = nil;
for (id object in self) {
if ([object isKindOfClass:[ALView class]]) {
ALView *view = (ALView *)object;
view.translatesAutoresizingMaskIntoConstraints = NO;
if (previousView) {
[constraints addObject:[view autoMatchDimension:dimension toDimension:dimension ofView:previousView]];
}
previousView = view;
}
}
return constraints;
}
/**
Sets the given dimension of all the views in this array to a given size.
Note: This array must contain at least 1 view.
@param dimension The dimension of each of the views to set.
@param size The size to set the given dimension of each view to.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimension:(ALDimension)dimension toSize:(CGFloat)size
{
NSAssert([self al_containsMinimumNumberOfViews:1], @"This array must contain at least 1 view.");
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
for (id object in self) {
if ([object isKindOfClass:[ALView class]]) {
ALView *view = (ALView *)object;
view.translatesAutoresizingMaskIntoConstraints = NO;
[constraints addObject:[view autoSetDimension:dimension toSize:size]];
}
}
return constraints;
}
/**
Sets all of the views in this array to a given size.
Note: This array must contain at least 1 view.
@param size The size to set each view's dimensions to.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimensionsToSize:(CGSize)size
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObjectsFromArray:[self autoSetViewsDimension:ALDimensionWidth toSize:size.width]];
[constraints addObjectsFromArray:[self autoSetViewsDimension:ALDimensionHeight toSize:size.height]];
return constraints;
}
/**
Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (variable) in the dimension along the axis and will have spacing (fixed) between them,
including from the first and last views to their superview.
@param axis The axis along which to distribute the views.
@param alignment The attribute to use to align all the views to one another.
@param spacing The fixed amount of spacing between each view.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
{
return [self autoDistributeViewsAlongAxis:axis
alignedTo:alignment
withFixedSpacing:spacing
insetSpacing:YES];
}
/**
Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (variable) in the dimension along the axis and will have spacing (fixed) between them.
The first and last views can optionally be inset from their superview by the same amount of spacing as between views.
@param axis The axis along which to distribute the views.
@param alignment The attribute to use to align all the views to one another.
@param spacing The fixed amount of spacing between each view.
@param shouldSpaceInsets Whether the first and last views should be equally inset from their superview.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
insetSpacing:(BOOL)shouldSpaceInsets
{
return [self autoDistributeViewsAlongAxis:axis
alignedTo:alignment
withFixedSpacing:spacing
insetSpacing:shouldSpaceInsets
matchedSizes:YES];
}
/**
Distributes the views in this array equally along the selected axis in their superview.
Views will have fixed spacing between them, and can optionally be constrained to the same size in the dimension along the axis.
The first and last views can optionally be inset from their superview by the same amount of spacing as between views.
@param axis The axis along which to distribute the views.
@param alignment The attribute to use to align all the views to one another.
@param spacing The fixed amount of spacing between each view.
@param shouldSpaceInsets Whether the first and last views should be equally inset from their superview.
@param shouldMatchSizes Whether all views will be constrained to be the same size in the dimension along the axis.
NOTE: All views must specify an intrinsic content size if passing NO, otherwise the layout will be ambiguous!
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
insetSpacing:(BOOL)shouldSpaceInsets
matchedSizes:(BOOL)shouldMatchSizes
{
NSAssert([self al_containsMinimumNumberOfViews:1], @"This array must contain at least 1 view to distribute.");
ALDimension matchedDimension;
ALEdge firstEdge, lastEdge;
switch (axis) {
case ALAxisHorizontal:
case ALAxisBaseline: // same value as ALAxisLastBaseline
#if __PureLayout_MinBaseSDK_iOS_8_0
case ALAxisFirstBaseline:
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
matchedDimension = ALDimensionWidth;
firstEdge = ALEdgeLeading;
lastEdge = ALEdgeTrailing;
break;
case ALAxisVertical:
matchedDimension = ALDimensionHeight;
firstEdge = ALEdgeTop;
lastEdge = ALEdgeBottom;
break;
default:
NSAssert(nil, @"Not a valid ALAxis.");
return nil;
}
CGFloat leadingSpacing = shouldSpaceInsets ? spacing : 0.0;
CGFloat trailingSpacing = shouldSpaceInsets ? spacing : 0.0;
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
ALView *previousView = nil;
for (id object in self) {
if ([object isKindOfClass:[ALView class]]) {
ALView *view = (ALView *)object;
view.translatesAutoresizingMaskIntoConstraints = NO;
if (previousView) {
// Second, Third, ... View
[constraints addObject:[view autoPinEdge:firstEdge toEdge:lastEdge ofView:previousView withOffset:spacing]];
if (shouldMatchSizes) {
[constraints addObject:[view autoMatchDimension:matchedDimension toDimension:matchedDimension ofView:previousView]];
}
[constraints addObject:[view al_alignAttribute:alignment toView:previousView forAxis:axis]];
}
else {
// First view
[constraints addObject:[view autoPinEdgeToSuperviewEdge:firstEdge withInset:leadingSpacing]];
}
previousView = view;
}
}
if (previousView) {
// Last View
[constraints addObject:[previousView autoPinEdgeToSuperviewEdge:lastEdge withInset:trailingSpacing]];
}
return constraints;
}
/**
Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (fixed) in the dimension along the axis and will have spacing (variable) between them,
including from the first and last views to their superview.
@param axis The axis along which to distribute the views.
@param alignment The attribute to use to align all the views to one another.
@param size The fixed size of each view in the dimension along the given axis.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSize:(CGFloat)size
{
return [self autoDistributeViewsAlongAxis:axis
alignedTo:alignment
withFixedSize:size
insetSpacing:YES];
}
/**
Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (fixed) in the dimension along the axis and will have spacing (variable) between them.
The first and last views can optionally be inset from their superview by the same amount of spacing as between views.
@param axis The axis along which to distribute the views.
@param alignment The attribute to use to align all the views to one another.
@param size The fixed size of each view in the dimension along the given axis.
@param shouldSpaceInsets Whether the first and last views should be equally inset from their superview.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSize:(CGFloat)size
insetSpacing:(BOOL)shouldSpaceInsets
{
NSAssert([self al_containsMinimumNumberOfViews:1], @"This array must contain at least 1 view to distribute.");
ALDimension fixedDimension;
NSLayoutAttribute attribute;
switch (axis) {
case ALAxisHorizontal:
case ALAxisBaseline: // same value as ALAxisLastBaseline
#if __PureLayout_MinBaseSDK_iOS_8_0
case ALAxisFirstBaseline:
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
fixedDimension = ALDimensionWidth;
attribute = NSLayoutAttributeCenterX;
break;
case ALAxisVertical:
fixedDimension = ALDimensionHeight;
attribute = NSLayoutAttributeCenterY;
break;
default:
NSAssert(nil, @"Not a valid ALAxis.");
return nil;
}
#if TARGET_OS_IPHONE
# if !defined(PURELAYOUT_APP_EXTENSIONS)
BOOL isRightToLeftLayout = [[UIApplication sharedApplication] userInterfaceLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft;
# else
// App Extensions may not access -[UIApplication sharedApplication]; fall back to checking the bundle's preferred localization character direction
BOOL isRightToLeftLayout = [NSLocale characterDirectionForLanguage:[[NSBundle mainBundle] preferredLocalizations][0]] == NSLocaleLanguageDirectionRightToLeft;
# endif /* !defined(PURELAYOUT_APP_EXTENSIONS) */
#else
BOOL isRightToLeftLayout = [[NSApplication sharedApplication] userInterfaceLayoutDirection] == NSUserInterfaceLayoutDirectionRightToLeft;
#endif /* TARGET_OS_IPHONE */
BOOL shouldFlipOrder = isRightToLeftLayout && (axis != ALAxisVertical); // imitate the effect of leading/trailing when distributing horizontally
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
__NSArray_of(ALView *) *views = [self al_copyViewsOnly];
NSUInteger numberOfViews = [views count];
ALView *commonSuperview = [views al_commonSuperviewOfViews];
ALView *previousView = nil;
for (NSUInteger i = 0; i < numberOfViews; i++) {
ALView *view = shouldFlipOrder ? views[numberOfViews - i - 1] : views[i];
view.translatesAutoresizingMaskIntoConstraints = NO;
[constraints addObject:[view autoSetDimension:fixedDimension toSize:size]];
CGFloat multiplier, constant;
if (shouldSpaceInsets) {
multiplier = (i * 2.0 + 2.0) / (numberOfViews + 1.0);
constant = (multiplier - 1.0) * size / 2.0;
} else {
multiplier = (i * 2.0) / (numberOfViews - 1.0);
constant = (-multiplier + 1.0) * size / 2.0;
}
// If the multiplier is very close to 0, set it to the minimum value to prevent the second item in the constraint from being lost. Filed as rdar://19168380
if (fabs(multiplier) < kMULTIPLIER_MIN_VALUE) {
multiplier = kMULTIPLIER_MIN_VALUE;
}
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:view attribute:attribute relatedBy:NSLayoutRelationEqual toItem:commonSuperview attribute:attribute multiplier:multiplier constant:constant];
[constraint autoInstall];
[constraints addObject:constraint];
if (previousView) {
[constraints addObject:[view al_alignAttribute:alignment toView:previousView forAxis:axis]];
}
previousView = view;
}
return constraints;
}
#pragma mark Internal Helper Methods
/**
Returns the common superview for the views in this array. If there is only one view in the array, its superview will be returned.
Raises an exception if the views in this array do not share a common superview.
@return The common superview for the views in this array.
*/
- (ALView *)al_commonSuperviewOfViews
{
ALView *commonSuperview = nil;
ALView *previousView = nil;
for (id object in self) {
if ([object isKindOfClass:[ALView class]]) {
ALView *view = (ALView *)object;
if (previousView) {
commonSuperview = [view al_commonSuperviewWithView:commonSuperview];
} else {
commonSuperview = view.superview;
}
previousView = view;
}
}
NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy.");
return commonSuperview;
}
/**
Determines whether this array contains a minimum number of views.
@param minimumNumberOfViews The minimum number of views to check for.
@return YES if this array contains at least the minimum number of views, NO otherwise.
*/
- (BOOL)al_containsMinimumNumberOfViews:(NSUInteger)minimumNumberOfViews
{
NSUInteger numberOfViews = 0;
for (id object in self) {
if ([object isKindOfClass:[ALView class]]) {
numberOfViews++;
if (numberOfViews >= minimumNumberOfViews) {
return YES;
}
}
}
return numberOfViews >= minimumNumberOfViews;
}
/**
Creates a copy of this array containing only the view objects in it.
@return A new array containing only the views that are in this array.
*/
- (__NSArray_of(ALView *) *)al_copyViewsOnly
{
__NSMutableArray_of(ALView *) *viewsOnlyArray = [NSMutableArray arrayWithCapacity:[self count]];
for (id object in self) {
if ([object isKindOfClass:[ALView class]]) {
[viewsOnlyArray addObject:object];
}
}
return viewsOnlyArray;
}
@end

View File

@ -0,0 +1,84 @@
//
// NSLayoutConstraint+PureLayout.h
// https://github.com/PureLayout/PureLayout
//
// Copyright (c) 2013-2015 Tyler Fox
//
// This code is distributed under the terms and conditions of the MIT license.
//
// 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 "PureLayoutDefines.h"
__PL_ASSUME_NONNULL_BEGIN
#pragma mark NSLayoutConstraint+PureLayout
/**
A category on NSLayoutConstraint that allows constraints to be easily installed & removed.
*/
@interface NSLayoutConstraint (PureLayout)
#pragma mark Batch Constraint Creation
/** Creates all of the constraints in the block, then installs (activates) them all at once.
All constraints created from calls to the PureLayout API in the block are returned in a single array.
This may be more efficient than installing (activating) each constraint one-by-one. */
+ (__NSArray_of(NSLayoutConstraint *) *)autoCreateAndInstallConstraints:(ALConstraintsBlock)block;
/** Creates all of the constraints in the block but prevents them from being automatically installed (activated).
All constraints created from calls to the PureLayout API in the block are returned in a single array. */
+ (__NSArray_of(NSLayoutConstraint *) *)autoCreateConstraintsWithoutInstalling:(ALConstraintsBlock)block;
#pragma mark Set Priority For Constraints
/** Sets the constraint priority to the given value for all constraints created using the PureLayout API within the given constraints block.
NOTE: This method will have no effect (and will NOT set the priority) on constraints created or added without using the PureLayout API! */
+ (void)autoSetPriority:(ALLayoutPriority)priority forConstraints:(ALConstraintsBlock)block;
#pragma mark Identify Constraints
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
/** Sets the identifier for all constraints created using the PureLayout API within the given constraints block.
NOTE: This method will have no effect (and will NOT set the identifier) on constraints created or added without using the PureLayout API! */
+ (void)autoSetIdentifier:(NSString *)identifier forConstraints:(ALConstraintsBlock)block;
/** Sets the string as the identifier for this constraint. Available in iOS 7.0 and OS X 10.9 and later. */
- (instancetype)autoIdentify:(NSString *)identifier;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#pragma mark Install & Remove Constraints
/** Activates the the constraint. */
- (void)autoInstall;
/** Deactivates the constraint. */
- (void)autoRemove;
@end
__PL_ASSUME_NONNULL_END

View File

@ -0,0 +1,552 @@
//
// NSLayoutConstraint+PureLayout.m
// https://github.com/PureLayout/PureLayout
//
// Copyright (c) 2013-2015 Tyler Fox
//
// This code is distributed under the terms and conditions of the MIT license.
//
// 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 "NSLayoutConstraint+PureLayout.h"
#import "ALView+PureLayout.h"
#import "NSArray+PureLayout.h"
#import "PureLayout+Internal.h"
#pragma mark - NSLayoutConstraint+PureLayout
@implementation NSLayoutConstraint (PureLayout)
#pragma mark Batch Constraint Creation
/**
A global variable that stores a stack of arrays of constraints created without being immediately installed.
When executing a constraints block passed into the +[autoCreateConstraintsWithoutInstalling:] method, a new
mutable array is pushed onto this stack, and all constraints created with PureLayout in the block are added
to this array. When the block finishes executing, the array is popped off this stack. Automatic constraint
installation is prevented if this stack contains at least 1 array.
NOTE: Access to this variable is not synchronized (and should only be done on the main thread).
*/
static __NSMutableArray_of(__NSMutableArray_of(NSLayoutConstraint *) *) *_al_arraysOfCreatedConstraints = nil;
/**
A global variable that is set to YES when installing a batch of constraints collected from a call to +[autoCreateAndInstallConstraints].
When this flag is YES, constraints are installed immediately without checking for or adding to the +[al_currentArrayOfCreatedConstraints].
This is necessary to properly handle nested calls to +[autoCreateAndInstallConstraints], where calls whose block contains other call(s)
should not return constraints from within the blocks of nested call(s).
*/
static BOOL _al_isInstallingCreatedConstraints = NO;
/**
Accessor for the global state that stores arrays of constraints created without being installed.
*/
+ (__NSMutableArray_of(__NSMutableArray_of(NSLayoutConstraint *) *) *)al_arraysOfCreatedConstraints
{
NSAssert([NSThread isMainThread], @"PureLayout is not thread safe, and must be used exclusively from the main thread.");
if (!_al_arraysOfCreatedConstraints) {
_al_arraysOfCreatedConstraints = [NSMutableArray new];
}
return _al_arraysOfCreatedConstraints;
}
/**
Accessor for the current mutable array of constraints created without being immediately installed.
*/
+ (__NSMutableArray_of(NSLayoutConstraint *) *)al_currentArrayOfCreatedConstraints
{
return [[self al_arraysOfCreatedConstraints] lastObject];
}
/**
Accessor for the global state that determines whether automatic constraint installation should be prevented.
*/
+ (BOOL)al_preventAutomaticConstraintInstallation
{
return (_al_isInstallingCreatedConstraints == NO) && ([[self al_arraysOfCreatedConstraints] count] > 0);
}
/**
Creates all of the constraints in the block, then installs (activates) them all at once.
All constraints created from calls to the PureLayout API in the block are returned in a single array.
This may be more efficient than installing (activating) each constraint one-by-one.
Note: calls to this method may be nested. The constraints returned from a call will NOT include constraints
created in nested calls; constraints are only returned from the inner-most call they are created within.
@param block A block of method calls to the PureLayout API that create constraints.
@return An array of the constraints that were created from calls to the PureLayout API inside the block.
*/
+ (__NSArray_of(NSLayoutConstraint *) *)autoCreateAndInstallConstraints:(ALConstraintsBlock)block
{
NSArray *createdConstraints = [self autoCreateConstraintsWithoutInstalling:block];
_al_isInstallingCreatedConstraints = YES;
[createdConstraints autoInstallConstraints];
_al_isInstallingCreatedConstraints = NO;
return createdConstraints;
}
/**
Creates all of the constraints in the block but prevents them from being automatically installed (activated).
All constraints created from calls to the PureLayout API in the block are returned in a single array.
Note: calls to this method may be nested. The constraints returned from a call will NOT include constraints
created in nested calls; constraints are only returned from the inner-most call they are created within.
@param block A block of method calls to the PureLayout API that create constraints.
@return An array of the constraints that were created from calls to the PureLayout API inside the block.
*/
+ (__NSArray_of(NSLayoutConstraint *) *)autoCreateConstraintsWithoutInstalling:(ALConstraintsBlock)block
{
NSAssert(block, @"The constraints block cannot be nil.");
NSArray *createdConstraints = nil;
if (block) {
[[self al_arraysOfCreatedConstraints] addObject:[NSMutableArray new]];
block();
createdConstraints = [self al_currentArrayOfCreatedConstraints];
[[self al_arraysOfCreatedConstraints] removeLastObject];
}
return createdConstraints;
}
#pragma mark Set Priority For Constraints
/**
A global variable that stores a stack of layout priorities to set on constraints.
When executing a constraints block passed into the +[autoSetPriority:forConstraints:] method, the priority for
that call is pushed onto this stack, and when the block finishes executing, that priority is popped off this
stack. If this stack contains at least 1 priority, the priority at the top of the stack will be set for all
constraints created by this library (even if automatic constraint installation is being prevented).
NOTE: Access to this variable is not synchronized (and should only be done on the main thread).
*/
static __NSMutableArray_of(NSNumber *) *_al_globalConstraintPriorities = nil;
/**
Accessor for the global stack of layout priorities.
*/
+ (__NSMutableArray_of(NSNumber *) *)al_globalConstraintPriorities
{
NSAssert([NSThread isMainThread], @"PureLayout is not thread safe, and must be used exclusively from the main thread.");
if (!_al_globalConstraintPriorities) {
_al_globalConstraintPriorities = [NSMutableArray new];
}
return _al_globalConstraintPriorities;
}
/**
Returns the current layout priority to use for constraints.
When executing a constraints block passed into +[autoSetPriority:forConstraints:], this will return
the priority for the current block. Otherwise, the default Required priority is returned.
*/
+ (ALLayoutPriority)al_currentGlobalConstraintPriority
{
__NSMutableArray_of(NSNumber *) *globalConstraintPriorities = [self al_globalConstraintPriorities];
if ([globalConstraintPriorities count] == 0) {
return ALLayoutPriorityRequired;
}
return [[globalConstraintPriorities lastObject] floatValue];
}
/**
Accessor for the global state that determines if we're currently in the scope of a priority constraints block.
*/
+ (BOOL)al_isExecutingPriorityConstraintsBlock
{
return [[self al_globalConstraintPriorities] count] > 0;
}
/**
Sets the constraint priority to the given value for all constraints created using the PureLayout
API within the given constraints block.
NOTE: This method will have no effect (and will NOT set the priority) on constraints created or added
without using the PureLayout API!
@param priority The layout priority to be set on all constraints created in the constraints block.
@param block A block of method calls to the PureLayout API that create and install constraints.
*/
+ (void)autoSetPriority:(ALLayoutPriority)priority forConstraints:(ALConstraintsBlock)block
{
NSAssert(block, @"The constraints block cannot be nil.");
if (block) {
[[self al_globalConstraintPriorities] addObject:@(priority)];
block();
[[self al_globalConstraintPriorities] removeLastObject];
}
}
#pragma mark Identify Constraints
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
/**
A global variable that stores a stack of identifier strings to set on constraints.
When executing a constraints block passed into the +[autoSetIdentifier:forConstraints:] method, the identifier for
that call is pushed onto this stack, and when the block finishes executing, that identifier is popped off this
stack. If this stack contains at least 1 identifier, the identifier at the top of the stack will be set for all
constraints created by this library (even if automatic constraint installation is being prevented).
NOTE: Access to this variable is not synchronized (and should only be done on the main thread).
*/
static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
/**
Accessor for the global state of constraint identifiers.
*/
+ (__NSMutableArray_of(NSString *) *)al_globalConstraintIdentifiers
{
NSAssert([NSThread isMainThread], @"PureLayout is not thread safe, and must be used exclusively from the main thread.");
if (!_al_globalConstraintIdentifiers) {
_al_globalConstraintIdentifiers = [NSMutableArray new];
}
return _al_globalConstraintIdentifiers;
}
/**
Returns the current identifier string to use for constraints.
When executing a constraints block passed into +[autoSetIdentifier:forConstraints:], this will return
the identifier for the current block. Otherwise, nil is returned.
*/
+ (NSString *)al_currentGlobalConstraintIdentifier
{
__NSMutableArray_of(NSString *) *globalConstraintIdentifiers = [self al_globalConstraintIdentifiers];
if ([globalConstraintIdentifiers count] == 0) {
return nil;
}
return [globalConstraintIdentifiers lastObject];
}
/**
Sets the identifier for all constraints created using the PureLayout API within the given constraints block.
NOTE: This method will have no effect (and will NOT set the identifier) on constraints created or added
without using the PureLayout API!
@param identifier A string used to identify all constraints created in the constraints block.
@param block A block of method calls to the PureLayout API that create and install constraints.
*/
+ (void)autoSetIdentifier:(NSString *)identifier forConstraints:(ALConstraintsBlock)block
{
NSAssert(block, @"The constraints block cannot be nil.");
NSAssert(identifier, @"The identifier string cannot be nil.");
if (block) {
if (identifier) {
[[self al_globalConstraintIdentifiers] addObject:identifier];
}
block();
if (identifier) {
[[self al_globalConstraintIdentifiers] removeLastObject];
}
}
}
/**
Sets the string as the identifier for this constraint. Available in iOS 7.0 and OS X 10.9 and later.
The identifier will be printed along with the constraint's description.
This is helpful to document a constraint's purpose and aid in debugging.
@param identifier A string used to identify this constraint.
@return This constraint.
*/
- (instancetype)autoIdentify:(NSString *)identifier
{
if ([self respondsToSelector:@selector(setIdentifier:)]) {
self.identifier = identifier;
}
return self;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#pragma mark Install & Remove Constraints
/**
Activates the constraint.
*/
- (void)autoInstall
{
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
if ([self respondsToSelector:@selector(setActive:)]) {
[NSLayoutConstraint al_applyGlobalStateToConstraint:self];
if ([NSLayoutConstraint al_preventAutomaticConstraintInstallation]) {
[[NSLayoutConstraint al_currentArrayOfCreatedConstraints] addObject:self];
} else {
self.active = YES;
}
return;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
NSAssert(self.firstItem || self.secondItem, @"Can't install a constraint with nil firstItem and secondItem.");
if (self.firstItem) {
if (self.secondItem) {
NSAssert([self.firstItem isKindOfClass:[ALView class]] && [self.secondItem isKindOfClass:[ALView class]], @"Can only automatically install a constraint if both items are views.");
ALView *commonSuperview = [self.firstItem al_commonSuperviewWithView:self.secondItem];
[commonSuperview al_addConstraint:self];
} else {
NSAssert([self.firstItem isKindOfClass:[ALView class]], @"Can only automatically install a constraint if the item is a view.");
[self.firstItem al_addConstraint:self];
}
} else {
NSAssert([self.secondItem isKindOfClass:[ALView class]], @"Can only automatically install a constraint if the item is a view.");
[self.secondItem al_addConstraint:self];
}
}
/**
Deactivates the constraint.
*/
- (void)autoRemove
{
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
if ([self respondsToSelector:@selector(setActive:)]) {
self.active = NO;
return;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
if (self.secondItem) {
ALView *commonSuperview = [self.firstItem al_commonSuperviewWithView:self.secondItem];
while (commonSuperview) {
if ([commonSuperview.constraints containsObject:self]) {
[commonSuperview removeConstraint:self];
return;
}
commonSuperview = commonSuperview.superview;
}
}
else {
[self.firstItem removeConstraint:self];
return;
}
NSAssert(nil, @"Failed to remove constraint: %@", self);
}
#pragma mark Internal Methods
/**
Applies the global constraint priority and identifier to the given constraint.
This should be done before installing all constraints.
@param constraint The constraint to set the global priority and identifier on.
*/
+ (void)al_applyGlobalStateToConstraint:(NSLayoutConstraint *)constraint
{
if ([NSLayoutConstraint al_isExecutingPriorityConstraintsBlock]) {
constraint.priority = [NSLayoutConstraint al_currentGlobalConstraintPriority];
}
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
NSString *globalConstraintIdentifier = [NSLayoutConstraint al_currentGlobalConstraintIdentifier];
if (globalConstraintIdentifier) {
[constraint autoIdentify:globalConstraintIdentifier];
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
}
/**
Returns the corresponding NSLayoutAttribute for the given ALAttribute.
@return The layout attribute for the given ALAttribute.
*/
+ (NSLayoutAttribute)al_layoutAttributeForAttribute:(ALAttribute)attribute
{
NSLayoutAttribute layoutAttribute = NSLayoutAttributeNotAnAttribute;
switch (attribute) {
case ALEdgeLeft:
layoutAttribute = NSLayoutAttributeLeft;
break;
case ALEdgeRight:
layoutAttribute = NSLayoutAttributeRight;
break;
case ALEdgeTop:
layoutAttribute = NSLayoutAttributeTop;
break;
case ALEdgeBottom:
layoutAttribute = NSLayoutAttributeBottom;
break;
case ALEdgeLeading:
layoutAttribute = NSLayoutAttributeLeading;
break;
case ALEdgeTrailing:
layoutAttribute = NSLayoutAttributeTrailing;
break;
case ALDimensionWidth:
layoutAttribute = NSLayoutAttributeWidth;
break;
case ALDimensionHeight:
layoutAttribute = NSLayoutAttributeHeight;
break;
case ALAxisVertical:
layoutAttribute = NSLayoutAttributeCenterX;
break;
case ALAxisHorizontal:
layoutAttribute = NSLayoutAttributeCenterY;
break;
case ALAxisBaseline: // same value as ALAxisLastBaseline
layoutAttribute = NSLayoutAttributeBaseline;
break;
#if __PureLayout_MinBaseSDK_iOS_8_0
case ALAxisFirstBaseline:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALAxisFirstBaseline is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeFirstBaseline;
break;
case ALMarginLeft:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeLeftMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeLeftMargin;
break;
case ALMarginRight:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeRightMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeRightMargin;
break;
case ALMarginTop:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeTopMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeTopMargin;
break;
case ALMarginBottom:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeBottomMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeBottomMargin;
break;
case ALMarginLeading:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeLeadingMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeLeadingMargin;
break;
case ALMarginTrailing:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeTrailingMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeTrailingMargin;
break;
case ALMarginAxisVertical:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALAxisVerticalMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeCenterXWithinMargins;
break;
case ALMarginAxisHorizontal:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALAxisHorizontalMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeCenterYWithinMargins;
break;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
default:
NSAssert(nil, @"Not a valid ALAttribute.");
break;
}
return layoutAttribute;
}
/**
Returns the corresponding ALLayoutConstraintAxis for the given ALAxis.
@return The constraint axis for the given axis.
*/
+ (ALLayoutConstraintAxis)al_constraintAxisForAxis:(ALAxis)axis
{
ALLayoutConstraintAxis constraintAxis;
switch (axis) {
case ALAxisVertical:
constraintAxis = ALLayoutConstraintAxisVertical;
break;
case ALAxisHorizontal:
case ALAxisBaseline: // same value as ALAxisLastBaseline
#if __PureLayout_MinBaseSDK_iOS_8_0
case ALAxisFirstBaseline:
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
constraintAxis = ALLayoutConstraintAxisHorizontal;
break;
default:
NSAssert(nil, @"Not a valid ALAxis.");
constraintAxis = ALLayoutConstraintAxisHorizontal; // default to an arbitrary value to satisfy the compiler
break;
}
return constraintAxis;
}
#if __PureLayout_MinBaseSDK_iOS_8_0
/**
Returns the corresponding margin for the given edge.
@param edge The edge to convert to the corresponding margin.
@return The margin for the given edge.
*/
+ (ALMargin)al_marginForEdge:(ALEdge)edge
{
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"Margin attributes are only supported on iOS 8.0 or higher.");
ALMargin margin;
switch (edge) {
case ALEdgeLeft:
margin = ALMarginLeft;
break;
case ALEdgeRight:
margin = ALMarginRight;
break;
case ALEdgeTop:
margin = ALMarginTop;
break;
case ALEdgeBottom:
margin = ALMarginBottom;
break;
case ALEdgeLeading:
margin = ALMarginLeading;
break;
case ALEdgeTrailing:
margin = ALMarginTrailing;
break;
default:
NSAssert(nil, @"Not a valid ALEdge.");
margin = ALMarginLeft; // default to an arbitrary value to satisfy the compiler
break;
}
return margin;
}
/**
Returns the corresponding margin axis for the given axis.
@param axis The axis to convert to the corresponding margin axis.
@return The margin axis for the given axis.
*/
+ (ALMarginAxis)al_marginAxisForAxis:(ALAxis)axis
{
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"Margin attributes are only supported on iOS 8.0 or higher.");
ALMarginAxis marginAxis;
switch (axis) {
case ALAxisVertical:
marginAxis = ALMarginAxisVertical;
break;
case ALAxisHorizontal:
marginAxis = ALMarginAxisHorizontal;
break;
case ALAxisBaseline:
case ALAxisFirstBaseline:
NSAssert(nil, @"The baseline axis attributes do not have corresponding margin axis attributes.");
marginAxis = ALMarginAxisVertical; // default to an arbitrary value to satisfy the compiler
break;
default:
NSAssert(nil, @"Not a valid ALAxis.");
marginAxis = ALMarginAxisVertical; // default to an arbitrary value to satisfy the compiler
break;
}
return marginAxis;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
@end

View File

@ -0,0 +1,87 @@
//
// PureLayout+Internal.h
// https://github.com/PureLayout/PureLayout
//
// Copyright (c) 2014-2015 Tyler Fox
//
// This code is distributed under the terms and conditions of the MIT license.
//
// 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 "PureLayoutDefines.h"
// Using generics with NSMutableArray is so common in the internal implementation of PureLayout that it gets a dedicated preprocessor macro for better readability.
#define __NSMutableArray_of(type) __PL_GENERICS(NSMutableArray, type)
__PL_ASSUME_NONNULL_BEGIN
/** A constant that represents the smallest valid positive value for the multiplier of a constraint,
since a value of 0 will cause the second item to be lost in the internal auto layout engine. */
static const CGFloat kMULTIPLIER_MIN_VALUE = (CGFloat)0.00001; // very small floating point numbers (e.g. CGFLOAT_MIN) can cause problems
/**
A category that exposes the internal (private) helper methods of the ALView+PureLayout category.
*/
@interface ALView (PureLayoutInternal)
- (void)al_addConstraint:(NSLayoutConstraint *)constraint;
- (ALView *)al_commonSuperviewWithView:(ALView *)otherView;
- (NSLayoutConstraint *)al_alignAttribute:(ALAttribute)attribute toView:(ALView *)otherView forAxis:(ALAxis)axis;
@end
/**
A category that exposes the internal (private) helper methods of the NSArray+PureLayout category.
*/
@interface NSArray (PureLayoutInternal)
- (ALView *)al_commonSuperviewOfViews;
- (BOOL)al_containsMinimumNumberOfViews:(NSUInteger)minimumNumberOfViews;
- (__NSArray_of(ALView *) *)al_copyViewsOnly;
@end
/**
A category that exposes the internal (private) helper methods of the NSLayoutConstraint+PureLayout category.
*/
@interface NSLayoutConstraint (PureLayoutInternal)
+ (BOOL)al_preventAutomaticConstraintInstallation;
+ (__NSMutableArray_of(NSLayoutConstraint *) *)al_currentArrayOfCreatedConstraints;
+ (BOOL)al_isExecutingPriorityConstraintsBlock;
+ (ALLayoutPriority)al_currentGlobalConstraintPriority;
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
+ (NSString *)al_currentGlobalConstraintIdentifier;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
+ (void)al_applyGlobalStateToConstraint:(NSLayoutConstraint *)constraint;
+ (NSLayoutAttribute)al_layoutAttributeForAttribute:(ALAttribute)attribute;
+ (ALLayoutConstraintAxis)al_constraintAxisForAxis:(ALAxis)axis;
#if __PureLayout_MinBaseSDK_iOS_8_0
+ (ALMargin)al_marginForEdge:(ALEdge)edge;
+ (ALMarginAxis)al_marginAxisForAxis:(ALAxis)axis;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
@end
__PL_ASSUME_NONNULL_END

View File

@ -0,0 +1,43 @@
//
// PureLayout.h
// https://github.com/PureLayout/PureLayout
//
// Copyright (c) 2014-2015 Tyler Fox
//
// This code is distributed under the terms and conditions of the MIT license.
//
// 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.
//
#ifndef PureLayout_h
#define PureLayout_h
#import <Foundation/Foundation.h>
//! Project version number for PureLayout.
FOUNDATION_EXPORT double PureLayoutVersionNumber;
//! Project version string for PureLayout.
FOUNDATION_EXPORT const unsigned char PureLayoutVersionString[];
#import "ALView+PureLayout.h"
#import "NSArray+PureLayout.h"
#import "NSLayoutConstraint+PureLayout.h"
#endif /* PureLayout_h */

View File

@ -0,0 +1,224 @@
//
// PureLayoutDefines.h
// https://github.com/PureLayout/PureLayout
//
// Copyright (c) 2014-2015 Tyler Fox
//
// This code is distributed under the terms and conditions of the MIT license.
//
// 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.
//
#ifndef PureLayoutDefines_h
#define PureLayoutDefines_h
#import <Foundation/Foundation.h>
// Define some preprocessor macros to check for a minimum Base SDK. These are used to prevent compile-time errors in older versions of Xcode.
#define __PureLayout_MinBaseSDK_iOS_8_0 (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1)
#define __PureLayout_MinBaseSDK_OSX_10_10 (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_9)
// Define some preprocessor macros to check for a minimum System Version. These are used to prevent runtime crashes on older versions of iOS/OS X.
#define __PureLayout_MinSysVer_iOS_7_0 (TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
#define __PureLayout_MinSysVer_iOS_8_0 (TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1)
#define __PureLayout_MinSysVer_OSX_10_9 (!TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8_4)
// Define some preprocessor macros that allow nullability annotations to be adopted in a backwards-compatible manner.
#if __has_feature(nullability)
# define __PL_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
# define __PL_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
#else
# define __PL_ASSUME_NONNULL_BEGIN
# define __PL_ASSUME_NONNULL_END
#endif
// Define some preprocessor macros that allow generics to be adopted in a backwards-compatible manner.
#if __has_feature(objc_generics)
# define __PL_GENERICS(class, ...) class<__VA_ARGS__>
#else
# define __PL_GENERICS(class, ...) class
#endif
// Using generics with NSArray is so common in PureLayout that it gets a dedicated preprocessor macro for better readability.
#define __NSArray_of(type) __PL_GENERICS(NSArray, type)
// Define generic AL-prefixed macros for the types/constants/etc that have slight naming variations across iOS and OS X, which allows the same code to be platform-independent.
#if TARGET_OS_IPHONE
# import <UIKit/UIKit.h>
# define ALView UIView
# define ALEdgeInsets UIEdgeInsets
# define ALEdgeInsetsZero UIEdgeInsetsZero
# define ALEdgeInsetsMake UIEdgeInsetsMake
# define ALLayoutConstraintAxis UILayoutConstraintAxis
# define ALLayoutConstraintOrientation ALLayoutConstraintAxis
# define ALLayoutConstraintAxisHorizontal UILayoutConstraintAxisHorizontal
# define ALLayoutConstraintAxisVertical UILayoutConstraintAxisVertical
# define ALLayoutConstraintOrientationHorizontal ALLayoutConstraintAxisHorizontal
# define ALLayoutConstraintOrientationVertical ALLayoutConstraintAxisVertical
# define ALLayoutPriority UILayoutPriority
# define ALLayoutPriorityRequired UILayoutPriorityRequired
# define ALLayoutPriorityDefaultHigh UILayoutPriorityDefaultHigh
# define ALLayoutPriorityDefaultLow UILayoutPriorityDefaultLow
# define ALLayoutPriorityFittingSizeLevel UILayoutPriorityFittingSizeLevel
# define ALLayoutPriorityFittingSizeCompression ALLayoutPriorityFittingSizeLevel
#else
# import <Cocoa/Cocoa.h>
# define ALView NSView
# define ALEdgeInsets NSEdgeInsets
# define ALEdgeInsetsZero NSEdgeInsetsMake(0, 0, 0, 0)
# define ALEdgeInsetsMake NSEdgeInsetsMake
# define ALLayoutConstraintOrientation NSLayoutConstraintOrientation
# define ALLayoutConstraintAxis ALLayoutConstraintOrientation
# define ALLayoutConstraintOrientationHorizontal NSLayoutConstraintOrientationHorizontal
# define ALLayoutConstraintOrientationVertical NSLayoutConstraintOrientationVertical
# define ALLayoutConstraintAxisHorizontal ALLayoutConstraintOrientationHorizontal
# define ALLayoutConstraintAxisVertical ALLayoutConstraintOrientationVertical
# define ALLayoutPriority NSLayoutPriority
# define ALLayoutPriorityRequired NSLayoutPriorityRequired
# define ALLayoutPriorityDefaultHigh NSLayoutPriorityDefaultHigh
# define ALLayoutPriorityDefaultLow NSLayoutPriorityDefaultLow
# define ALLayoutPriorityFittingSizeCompression NSLayoutPriorityFittingSizeCompression
# define ALLayoutPriorityFittingSizeLevel ALLayoutPriorityFittingSizeCompression
#endif /* TARGET_OS_IPHONE */
#pragma mark PureLayout Attributes
/** Constants that represent edges of a view. */
typedef NS_ENUM(NSInteger, ALEdge) {
/** The left edge of the view. */
ALEdgeLeft = NSLayoutAttributeLeft,
/** The right edge of the view. */
ALEdgeRight = NSLayoutAttributeRight,
/** The top edge of the view. */
ALEdgeTop = NSLayoutAttributeTop,
/** The bottom edge of the view. */
ALEdgeBottom = NSLayoutAttributeBottom,
/** The leading edge of the view (left edge for left-to-right languages like English, right edge for right-to-left languages like Arabic). */
ALEdgeLeading = NSLayoutAttributeLeading,
/** The trailing edge of the view (right edge for left-to-right languages like English, left edge for right-to-left languages like Arabic). */
ALEdgeTrailing = NSLayoutAttributeTrailing
};
/** Constants that represent dimensions of a view. */
typedef NS_ENUM(NSInteger, ALDimension) {
/** The width of the view. */
ALDimensionWidth = NSLayoutAttributeWidth,
/** The height of the view. */
ALDimensionHeight = NSLayoutAttributeHeight
};
/** Constants that represent axes of a view. */
typedef NS_ENUM(NSInteger, ALAxis) {
/** A vertical line equidistant from the view's left and right edges. */
ALAxisVertical = NSLayoutAttributeCenterX,
/** A horizontal line equidistant from the view's top and bottom edges. */
ALAxisHorizontal = NSLayoutAttributeCenterY,
/** A horizontal line at the baseline of the last line of text in the view. (For views that do not draw text, will be equivalent to ALEdgeBottom.) Same as ALAxisLastBaseline. */
ALAxisBaseline = NSLayoutAttributeBaseline,
/** A horizontal line at the baseline of the last line of text in the view. (For views that do not draw text, will be equivalent to ALEdgeBottom.) */
ALAxisLastBaseline = ALAxisBaseline,
#if __PureLayout_MinBaseSDK_iOS_8_0
/** A horizontal line at the baseline of the first line of text in a view. (For views that do not draw text, will be equivalent to ALEdgeTop.) Available in iOS 8.0 and later. */
ALAxisFirstBaseline = NSLayoutAttributeFirstBaseline
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
};
#if __PureLayout_MinBaseSDK_iOS_8_0
/** Constants that represent layout margins of a view. Available in iOS 8.0 and later. */
typedef NS_ENUM(NSInteger, ALMargin) {
/** The left margin of the view, based on the view's layoutMargins left inset. */
ALMarginLeft = NSLayoutAttributeLeftMargin,
/** The right margin of the view, based on the view's layoutMargins right inset. */
ALMarginRight = NSLayoutAttributeRightMargin,
/** The top margin of the view, based on the view's layoutMargins top inset. */
ALMarginTop = NSLayoutAttributeTopMargin,
/** The bottom margin of the view, based on the view's layoutMargins bottom inset. */
ALMarginBottom = NSLayoutAttributeBottomMargin,
/** The leading margin of the view, based on the view's layoutMargins left/right (depending on language direction) inset. */
ALMarginLeading = NSLayoutAttributeLeadingMargin,
/** The trailing margin of the view, based on the view's layoutMargins left/right (depending on language direction) inset. */
ALMarginTrailing = NSLayoutAttributeTrailingMargin
};
/** Constants that represent axes of the layout margins of a view. Available in iOS 8.0 and later. */
typedef NS_ENUM(NSInteger, ALMarginAxis) {
/** A vertical line equidistant from the view's left and right margins. */
ALMarginAxisVertical = NSLayoutAttributeCenterXWithinMargins,
/** A horizontal line equidistant from the view's top and bottom margins. */
ALMarginAxisHorizontal = NSLayoutAttributeCenterYWithinMargins
};
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
/** An attribute of a view that can be used in auto layout constraints. These constants are identical to the more specific enum types:
ALEdge, ALAxis, ALDimension, ALMargin, ALMarginAxis. It is safe to cast a more specific enum type to the ALAttribute type. */
typedef NS_ENUM(NSInteger, ALAttribute) {
/** The left edge of the view. */
ALAttributeLeft = ALEdgeLeft,
/** The right edge of the view. */
ALAttributeRight = ALEdgeRight,
/** The top edge of the view. */
ALAttributeTop = ALEdgeTop,
/** The bottom edge of the view. */
ALAttributeBottom = ALEdgeBottom,
/** The leading edge of the view (left edge for left-to-right languages like English, right edge for right-to-left languages like Arabic). */
ALAttributeLeading = ALEdgeLeading,
/** The trailing edge of the view (right edge for left-to-right languages like English, left edge for right-to-left languages like Arabic). */
ALAttributeTrailing = ALEdgeTrailing,
/** The width of the view. */
ALAttributeWidth = ALDimensionWidth,
/** The height of the view. */
ALAttributeHeight = ALDimensionHeight,
/** A vertical line equidistant from the view's left and right edges. */
ALAttributeVertical = ALAxisVertical,
/** A horizontal line equidistant from the view's top and bottom edges. */
ALAttributeHorizontal = ALAxisHorizontal,
/** A horizontal line at the baseline of the last line of text in the view. (For views that do not draw text, will be equivalent to ALEdgeBottom.) Same as ALAxisLastBaseline. */
ALAttributeBaseline = ALAxisBaseline,
/** A horizontal line at the baseline of the last line of text in the view. (For views that do not draw text, will be equivalent to ALEdgeBottom.) */
ALAttributeLastBaseline = ALAxisLastBaseline,
#if __PureLayout_MinBaseSDK_iOS_8_0
/** A horizontal line at the baseline of the first line of text in a view. (For views that do not draw text, will be equivalent to ALEdgeTop.) Available in iOS 8.0 and later. */
ALAttributeFirstBaseline = ALAxisFirstBaseline,
/** The left margin of the view, based on the view's layoutMargins left inset. */
ALAttributeMarginLeft = ALMarginLeft,
/** The right margin of the view, based on the view's layoutMargins right inset. */
ALAttributeMarginRight = ALMarginRight,
/** The top margin of the view, based on the view's layoutMargins top inset. */
ALAttributeMarginTop = ALMarginTop,
/** The bottom margin of the view, based on the view's layoutMargins bottom inset. */
ALAttributeMarginBottom = ALMarginBottom,
/** The leading margin of the view, based on the view's layoutMargins left/right (depending on language direction) inset. */
ALAttributeMarginLeading = ALMarginLeading,
/** The trailing margin of the view, based on the view's layoutMargins left/right (depending on language direction) inset. */
ALAttributeMarginTrailing = ALMarginTrailing,
/** A vertical line equidistant from the view's left and right margins. */
ALAttributeMarginAxisVertical = ALMarginAxisVertical,
/** A horizontal line equidistant from the view's top and bottom margins. */
ALAttributeMarginAxisHorizontal = ALMarginAxisHorizontal
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
};
/** A block containing method calls to the PureLayout API. Takes no arguments and has no return value. */
typedef void(^ALConstraintsBlock)(void);
#endif /* PureLayoutDefines_h */

219
Example/Pods/PureLayout/README.md generated Normal file
View File

@ -0,0 +1,219 @@
# [![PureLayout](https://github.com/PureLayout/PureLayout/blob/master/Images/PureLayout.png?raw=true)](#)
[![Build Status](http://img.shields.io/travis/PureLayout/PureLayout.svg?style=flat)](https://travis-ci.org/PureLayout/PureLayout) [![Test Coverage](http://img.shields.io/coveralls/PureLayout/PureLayout.svg?style=flat)](https://coveralls.io/r/PureLayout/PureLayout) [![Version](http://img.shields.io/cocoapods/v/PureLayout.svg?style=flat)](http://cocoapods.org/?q=PureLayout) [![Platform](http://img.shields.io/cocoapods/p/PureLayout.svg?style=flat)](http://cocoapods.org/?q=PureLayout) [![License](http://img.shields.io/cocoapods/l/PureLayout.svg?style=flat)](LICENSE)
The ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. PureLayout extends `UIView`/`NSView`, `NSArray`, and `NSLayoutConstraint` with a comprehensive Auto Layout API that is modeled after Apple's own frameworks. PureLayout is a cross-platform Objective-C library that works (and looks!) great in Swift. It is fully backwards-compatible with all versions of iOS and OS X that support Auto Layout.
Writing Auto Layout code from scratch isn't easy. PureLayout provides a fully capable and developer-friendly interface for Auto Layout. It is designed for clarity and simplicity, and takes inspiration from the AutoLayout UI options available in Interface Builder while delivering far more flexibility. The API is also highly efficient, as it adds only a thin layer of third party code and is engineered for maximum performance.
### Table of Contents
1. [Setup](#setup)
1. [API Cheat Sheet](#api-cheat-sheet)
1. [Usage](#usage)
* [Sample Code](#sample-code-swift)
* [Example Apps](#example-apps)
1. [PureLayout vs. the rest](#purelayout-vs-the-rest)
1. [Problems, Suggestions, Pull Requests?](#problems-suggestions-pull-requests)
## Setup
### Compatibility
The current release of PureLayout supports all versions of iOS and OS X since the introduction of Auto Layout on each platform, in both Swift and Objective-C, with a single codebase!
* Xcode
* Language Support: **Swift** *(any version)*, **Objective-C**
* Fully Compatible With: **Xcode 7.0**
* Minimum Supported Version: **Xcode 5.0**
* iOS
* Fully Compatible With: **iOS 9.0**
* Minimum Deployment Target: **iOS 6.0**
* OS X
* Fully Compatible With: **OS X 10.11**
* Minimum Deployment Target: **OS X 10.7**
### Using [CocoaPods](http://cocoapods.org)
1. Add the pod `PureLayout` to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html).
```ruby
pod 'PureLayout'
```
1. Run `pod install` from Terminal, then open your app's `.xcworkspace` file to launch Xcode.
1. Import the `PureLayout.h` umbrella header.
* With `use_frameworks!` in your Podfile
* Swift: `import PureLayout`
* Objective-C: `#import <PureLayout/PureLayout.h>` (or with Modules enabled: `@import PureLayout;`)
* Without `use_frameworks!` in your Podfile
* Swift: Add `#import "PureLayout.h"` to your bridging header.
* Objective-C: `#import "PureLayout.h"`
That's it - now go write some beautiful Auto Layout code!
### Using [Carthage](https://github.com/Carthage/Carthage)
1. Add the `PureLayout/PureLayout` project to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile).
```ogdl
github "PureLayout/PureLayout"
```
1. Run `carthage update`, then follow the [additional steps required](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) to add the framework into your project.
1. Import the PureLayout framework/module.
* Swift: `import PureLayout`
* Objective-C: `#import <PureLayout/PureLayout.h>` (or with Modules enabled: `@import PureLayout;`)
That's it - now go write some beautiful Auto Layout code!
### Manually from GitHub
1. Download the source files in the [PureLayout subdirectory](PureLayout/PureLayout).
1. Add the source files to your Xcode project.
1. Import the `PureLayout.h` header.
* Swift: Add `#import "PureLayout.h"` to your bridging header.
* Objective-C: `#import "PureLayout.h"`
That's it - now go write some beautiful Auto Layout code!
### App Extensions
To use PureLayout in an App Extension, you need to do a bit of extra configuration to prevent usage of unavailable APIs. [Click here](https://github.com/PureLayout/PureLayout/wiki/App-Extensions) for more info.
### Releases
Releases are tagged in the git commit history using [semantic versioning](http://semver.org). Check out the [releases and release notes](https://github.com/PureLayout/PureLayout/releases) for each version.
## API Cheat Sheet
This is just a handy overview of the core API methods. Explore the [header files](PureLayout/PureLayout) for the full API, and find the complete documentation above the implementation of each method in the corresponding .m file. A couple of notes:
* All of the public API methods are namespaced with the prefix `auto...`, which also makes it easy for Xcode to autocomplete as you type.
* Methods that create constraints also automatically install (activate) the constraint(s), then return the new constraint(s) for you to optionally store for later adjustment or removal.
* Many methods below also have a variant which includes a `relation:` parameter to make the constraint an inequality.
### Attributes
PureLayout defines view attributes that are used to create auto layout constraints. Here is an [illustration of the most common attributes](Images/PureLayout-CommonAttributes.png).
There are 5 specific attribute types, which are used throughout most of the API:
* `ALEdge`
* `ALDimension`
* `ALAxis`
* `ALMargin` *available in iOS 8.0 and higher only*
* `ALMarginAxis` *available in iOS 8.0 and higher only*
Additionally, there is one generic attribute type, `ALAttribute`, which is effectively a union of all the specific types. You can think of this as the "supertype" of all of the specific attribute types, which means that it is always safe to cast a specific type to the generic `ALAttribute` type. (Note that the reverse is not true -- casting a generic ALAttribute to a specific attribute type is unsafe!)
### [`UIView`/`NSView`](PureLayout/PureLayout/ALView%2BPureLayout.h)
```
- autoSetContent(CompressionResistance|Hugging)PriorityForAxis:
- autoCenterInSuperview(Margins): // Margins variant iOS 8.0+ only
- autoAlignAxisToSuperview(Margin)Axis: // Margin variant iOS 8.0+ only
- autoPinEdgeToSuperview(Edge:|Margin:)(withInset:) // Margin variant iOS 8.0+ only
- autoPinEdgesToSuperview(Edges|Margins)(WithInsets:)(excludingEdge:) // Margins variant iOS 8.0+ only
- autoPinEdge:toEdge:ofView:(withOffset:)
- autoAlignAxis:toSameAxisOfView:(withOffset:|withMultiplier:)
- autoMatchDimension:toDimension:ofView:(withOffset:|withMultiplier:)
- autoSetDimension(s)ToSize:
- autoConstrainAttribute:toAttribute:ofView:(withOffset:|withMultiplier:)
- autoPinTo(Top|Bottom)LayoutGuideOfViewController:withInset: // iOS only
```
### [`NSArray`](PureLayout/PureLayout/NSArray%2BPureLayout.h)
```
// Arrays of Constraints
- autoInstallConstraints
- autoRemoveConstraints
- autoIdentifyConstraints: // iOS 7.0+, OS X 10.9+ only
// Arrays of Views
- autoAlignViewsToEdge:
- autoAlignViewsToAxis:
- autoMatchViewsDimension:
- autoSetViewsDimension:toSize:
- autoSetViewsDimensionsToSize:
- autoDistributeViewsAlongAxis:alignedTo:withFixedSpacing:(insetSpacing:)(matchedSizes:)
- autoDistributeViewsAlongAxis:alignedTo:withFixedSize:(insetSpacing:)
```
### [`NSLayoutConstraint`](PureLayout/PureLayout/NSLayoutConstraint%2BPureLayout.h)
```
+ autoCreateAndInstallConstraints:
+ autoCreateConstraintsWithoutInstalling:
+ autoSetPriority:forConstraints:
+ autoSetIdentifier:forConstraints: // iOS 7.0+, OS X 10.9+ only
- autoIdentify: // iOS 7.0+, OS X 10.9+ only
- autoInstall
- autoRemove
```
## Usage
### Sample Code (Swift)
PureLayout dramatically simplifies writing Auto Layout code. Let's take a quick look at some examples, using PureLayout from Swift.
Here's a constraint between two views created (and automatically activated) using PureLayout:
```swift
view1.autoPinEdge(.Top, toEdge: .Bottom, ofView: view2)
```
Without PureLayout, here's the equivalent code you'd have to write using Apple's Foundation API directly:
```swift
NSLayoutConstraint(item: view1, attribute: .Top, relatedBy: .Equal, toItem: view2, attribute: .Bottom, multiplier: 1.0, constant: 0.0).active = true
```
Many APIs of PureLayout create multiple constraints for you under the hood, letting you write highly readable layout code:
```swift
// 2 constraints created & activated in one line!
logoImageView.autoCenterInSuperview()
// 4 constraints created & activated in one line!
textContentView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsets(top: 20.0, left: 5.0, bottom: 10.0, right: 5.0))
```
PureLayout always returns the constraints it creates so you have full control:
```swift
let constraint = skinnyView.autoMatchDimension(.Height, toDimension: .Width, ofView: tallView)
```
PureLayout supports all Auto Layout features including inequalities, priorities, layout margins, identifiers, and much more. It's a comprehensive, developer-friendly way to use Auto Layout.
Check out the example apps below for many more demos of PureLayout in use.
### Example Apps
Open the project included in the repository (requires Xcode 6 or higher). It contains [iOS](PureLayout/Example-iOS) (`Example-iOS` scheme) and [OS X](PureLayout/Example-Mac) (`Example-Mac` scheme) demos of the library being used in various scenarios. The demos in the iOS example app make a great introductory tutorial to PureLayout -- run each demo, review the code used to implement it, then practice by making some changes of your own to the demo code.
Each demo in the iOS example app has a Swift and Objective-C version. **To compile & run the Swift demos, you must use Xcode 7.0 or higher (Swift 2.0) and choose the `Example-iOS-Xcode7` scheme.** When you run the example app, you can easily switch between using the Swift and Objective-C versions of the demos. To see the constraints in action while running the iOS demos, try using different device simulators, rotating the device to different orientations, as well as toggling the taller in-call status bar in the iOS Simulator.
On OS X, while running the app, press any key to cycle through the demos. You can resize the window to see the constraints in action.
### Tips and Tricks
Check out some [Tips and Tricks](https://github.com/PureLayout/PureLayout/wiki/Tips-and-Tricks) to keep in mind when using the API.
## PureLayout vs. the rest
There are quite a few different ways to implement Auto Layout. Here is a quick overview of the available options:
* Apple [NSLayoutConstraint SDK API](https://developer.apple.com/library/ios/documentation/AppKit/Reference/NSLayoutConstraint_Class/index.html#//apple_ref/occ/clm/NSLayoutConstraint/constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:)
* Pros: Raw power
* Cons: Extremely verbose; tedious to write; difficult to read
* Apple [Visual Format Language](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage/VisualFormatLanguage.html)
* Pros: Concise; convenient
* Cons: Doesn't support some use cases; lacks compile-time checking and safety; must learn syntax; hard to debug
* Apple Interface Builder
* Pros: Visual; interactive; provides compile-time layout checking
* Cons: Difficult for complex layouts; cannot dynamically set constraints at runtime; encourages hardcoded magic numbers; not always WYSIWYG
* Apple [NSLayoutAnchor SDK API](https://developer.apple.com/library/prerelease/ios/documentation/AppKit/Reference/NSLayoutAnchor_ClassReference/index.html)
* Pros: Clean, readable, and type-safe API for creating individual constraints
* Cons: Only available in iOS 9.0 and OS X 10.11 and higher; requires manually activating each constraint; no API for creating multiple constraints at once
* **PureLayout**
* Pros: Compatible with Objective-C and Swift codebases; consistent with Cocoa API style; cross-platform API and implementation shared across iOS and OS X; fully backwards-compatible to iOS 6 & OS X 10.7; easy to use; type-safe; efficient
* Cons: Not the most concise expression of layout code
* High-level Auto Layout Libraries/DSLs ([Cartography](https://github.com/robb/Cartography), [SnapKit](https://github.com/SnapKit/SnapKit), [KeepLayout](https://github.com/iMartinKiss/KeepLayout))
* Pros: Very clean, concise, and convenient
* Cons: Unique API style is foreign to Apple's APIs; mixed compatibility with Objective-C & Swift; greater dependency on third party code
PureLayout takes a balanced approach to Auto Layout that makes it well suited for any project.
## Problems, Suggestions, Pull Requests?
Please open a [new Issue here](https://github.com/PureLayout/PureLayout/issues/new) if you run into a problem specific to PureLayout, have a feature request, or want to share a comment. Note that general Auto Layout questions should be asked on [Stack Overflow](http://stackoverflow.com).
Pull requests are encouraged and greatly appreciated! Please try to maintain consistency with the existing code style. If you're considering taking on significant changes or additions to the project, please communicate in advance by opening a new Issue. This allows everyone to get onboard with upcoming changes, ensures that changes align with the project's design philosophy, and avoids duplicated work.
## Meta
Originally designed & built by Tyler Fox ([@smileyborg](https://github.com/smileyborg)). Currently maintained by Mickey Reiss ([@mickeyreiss](https://github.com/mickeyreiss)). Distributed with the MIT license.

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -0,0 +1,135 @@
# Acknowledgements
This application makes use of the following third party libraries:
## PureLayout
This code is distributed under the terms and conditions of the MIT license.
Copyright (c) 2014-2015 Tyler Fox
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.
## UIActionSheet-Blocks
Copyright (C) 2013 Developed by Shai Mishali
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.
## UIAlertViewBlockExtension
The MIT License (MIT)
Copyright (c) 2015 mangofever
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.
## pop
BSD License
For Pop software
Copyright (c) 2014, Facebook, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## TabBarPicker
Copyright (c) 2015 Giuseppe Nucifora <me@giuseppenucifora.com>
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.
## UIView-Overlay
The MIT License (MIT)
Copyright (c) 2015 lanserxt
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.
Generated by CocoaPods - http://cocoapods.org

View File

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>FooterText</key>
<string>This application makes use of the following third party libraries:</string>
<key>Title</key>
<string>Acknowledgements</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>This code is distributed under the terms and conditions of the MIT license.
Copyright (c) 2014-2015 Tyler Fox
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.
</string>
<key>Title</key>
<string>PureLayout</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (C) 2013 Developed by Shai Mishali
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.
</string>
<key>Title</key>
<string>UIActionSheet-Blocks</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>The MIT License (MIT)
Copyright (c) 2015 mangofever
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.
</string>
<key>Title</key>
<string>UIAlertViewBlockExtension</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>BSD License
For Pop software
Copyright (c) 2014, Facebook, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</string>
<key>Title</key>
<string>pop</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (c) 2015 Giuseppe Nucifora &lt;me@giuseppenucifora.com&gt;
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.
</string>
<key>Title</key>
<string>TabBarPicker</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>The MIT License (MIT)
Copyright (c) 2015 lanserxt
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.
</string>
<key>Title</key>
<string>UIView-Overlay</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Generated by CocoaPods - http://cocoapods.org</string>
<key>Title</key>
<string></string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
</array>
<key>StringsTable</key>
<string>Acknowledgements</string>
<key>Title</key>
<string>Acknowledgements</string>
</dict>
</plist>

View File

@ -0,0 +1,5 @@
#import <Foundation/Foundation.h>
@interface PodsDummy_Pods_TabBarPicker_Example : NSObject
@end
@implementation PodsDummy_Pods_TabBarPicker_Example
@end

Some files were not shown because too many files have changed in this diff Show More