Skip to content

Commit

Permalink
Complete safeArea
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc Dion committed Mar 19, 2018
1 parent 2d504e1 commit e5334c2
Show file tree
Hide file tree
Showing 38 changed files with 944 additions and 185 deletions.
38 changes: 37 additions & 1 deletion Example/PinLayoutSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
24F75B5B1EE5644E008DB567 /* IntroView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24F75B591EE5644E008DB567 /* IntroView.swift */; };
24F75B5C1EE5644E008DB567 /* IntroViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24F75B5A1EE5644E008DB567 /* IntroViewController.swift */; };
DE6C3D736B571B80E207DF6A /* Pods_PinLayoutSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AAD69688AA2A3F0994F3074E /* Pods_PinLayoutSample.framework */; };
DF4C1AA4205AEDFC00DED50B /* SafeAreaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF4C1AA0205AEDFC00DED50B /* SafeAreaView.swift */; };
DF4C1AA5205AEDFC00DED50B /* SafeAreaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF4C1AA1205AEDFC00DED50B /* SafeAreaViewController.swift */; };
DF4C1AAA205AF10900DED50B /* RoundedButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF4C1AA7205AF10900DED50B /* RoundedButton.swift */; };
DF4C1AAE205AF78A00DED50B /* SafeAreaCornersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF4C1AAC205AF78A00DED50B /* SafeAreaCornersViewController.swift */; };
DF4C1AAF205AF78A00DED50B /* SafeAreaCornersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF4C1AAD205AF78A00DED50B /* SafeAreaCornersView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -146,6 +151,11 @@
A35A00E6536E49A548E763E6 /* Pods-PinLayoutSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PinLayoutSample.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-PinLayoutSample/Pods-PinLayoutSample.debug.xcconfig"; sourceTree = "<group>"; };
AAD69688AA2A3F0994F3074E /* Pods_PinLayoutSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PinLayoutSample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C589624E868FCB20F7C10918 /* Pods-PinLayoutSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PinLayoutSample.release.xcconfig"; path = "../Pods/Target Support Files/Pods-PinLayoutSample/Pods-PinLayoutSample.release.xcconfig"; sourceTree = "<group>"; };
DF4C1AA0205AEDFC00DED50B /* SafeAreaView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SafeAreaView.swift; sourceTree = "<group>"; };
DF4C1AA1205AEDFC00DED50B /* SafeAreaViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SafeAreaViewController.swift; sourceTree = "<group>"; };
DF4C1AA7205AF10900DED50B /* RoundedButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoundedButton.swift; sourceTree = "<group>"; };
DF4C1AAC205AF78A00DED50B /* SafeAreaCornersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SafeAreaCornersViewController.swift; sourceTree = "<group>"; };
DF4C1AAD205AF78A00DED50B /* SafeAreaCornersView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SafeAreaCornersView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -207,13 +217,14 @@
24F75B581EE5642C008DB567 /* Intro */,
24CB99991F290591004EA7FB /* AdjustToContainer */,
DF66F9D61E8493D400ADB8D5 /* AutoAdjustingSize */,
24A9C1EF1EF0542500F2CF64 /* TableViewExample */,
24F2460C1FA8D4D100B6332E /* CollectionViewExample */,
DF4C1A9F205AEDFC00DED50B /* SafeArea */,
2497CFEA1EF40B8100DFD13B /* Form */,
24D18D181F3DECD6008129EF /* IntroRTL */,
2416376F1F8E4BC200EE703A /* IntroObjectiveC */,
2439CC5F1E665F66003326FB /* MultiRelativeView */,
2439CC631E66606D003326FB /* RelativeView */,
24A9C1EF1EF0542500F2CF64 /* TableViewExample */,
24CD1E8D1F8E4B0A00C3A54D /* PinLayoutSample-Bridging-Header.h */,
);
path = Examples;
Expand Down Expand Up @@ -371,6 +382,26 @@
path = Intro;
sourceTree = "<group>";
};
DF4C1A9F205AEDFC00DED50B /* SafeArea */ = {
isa = PBXGroup;
children = (
DF4C1AAB205AF10C00DED50B /* Subviews */,
DF4C1AA0205AEDFC00DED50B /* SafeAreaView.swift */,
DF4C1AA1205AEDFC00DED50B /* SafeAreaViewController.swift */,
DF4C1AAD205AF78A00DED50B /* SafeAreaCornersView.swift */,
DF4C1AAC205AF78A00DED50B /* SafeAreaCornersViewController.swift */,
);
path = SafeArea;
sourceTree = "<group>";
};
DF4C1AAB205AF10C00DED50B /* Subviews */ = {
isa = PBXGroup;
children = (
DF4C1AA7205AF10900DED50B /* RoundedButton.swift */,
);
path = Subviews;
sourceTree = "<group>";
};
DF66F9D61E8493D400ADB8D5 /* AutoAdjustingSize */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -565,6 +596,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DF4C1AAF205AF78A00DED50B /* SafeAreaCornersView.swift in Sources */,
24F246141FA8D57100B6332E /* UIImageView+Download.swift in Sources */,
24DA374B1EF7F90600D1AB2F /* BaseFormView.swift in Sources */,
24F75B5C1EE5644E008DB567 /* IntroViewController.swift in Sources */,
Expand All @@ -574,22 +606,26 @@
247157941F87BD680003424F /* UIEdgeInsets+PinLayout.swift in Sources */,
24D18D1E1F3DED0D008129EF /* IntroRTLViewController.swift in Sources */,
24F246121FA8D4D100B6332E /* HouseCell.swift in Sources */,
DF4C1AAE205AF78A00DED50B /* SafeAreaCornersViewController.swift in Sources */,
24A9C2031EF16A3E00F2CF64 /* AutoAdjustingSizeView.swift in Sources */,
24D18D1D1F3DED0D008129EF /* IntroRTLView.swift in Sources */,
DF4C1AAA205AF10900DED50B /* RoundedButton.swift in Sources */,
2439CC351E665BF6003326FB /* MenuView.swift in Sources */,
2439CC4B1E665C6B003326FB /* BasicView.swift in Sources */,
24A9C1F61EF054BF00F2CF64 /* MethodCell.swift in Sources */,
24A9C2041EF16A3E00F2CF64 /* AutoAdjustingSizeViewController.swift in Sources */,
24CB999C1F29059B004EA7FB /* AdjustToContainerView.swift in Sources */,
2497CFED1EF40B9100DFD13B /* FormView.swift in Sources */,
24F75B5B1EE5644E008DB567 /* IntroView.swift in Sources */,
DF4C1AA5205AEDFC00DED50B /* SafeAreaViewController.swift in Sources */,
249EFE431E64FAFE00165E39 /* AppDelegate.swift in Sources */,
2497CFEE1EF40B9100DFD13B /* FormViewController.swift in Sources */,
24A9C1F31EF0542F00F2CF64 /* TableViewExampleViewController.swift in Sources */,
24CB99981F290540004EA7FB /* MethodGroupHeader.swift in Sources */,
2439CC361E665BF6003326FB /* MenuViewController.swift in Sources */,
24F246111FA8D4D100B6332E /* CollectionViewExampleViewController.swift in Sources */,
2439CC531E665C6B003326FB /* MultiRelativeViewController.swift in Sources */,
DF4C1AA4205AEDFC00DED50B /* SafeAreaView.swift in Sources */,
241637771F8E4F9100EE703A /* IntroObjectiveCView.m in Sources */,
24CB99A01F290664004EA7FB /* ChoiceSelectorView.swift in Sources */,
249326891EEEEE3D00BCB814 /* Stylesheet.swift in Sources */,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Arrow.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "arrow_corner_tl.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "icon_scan barcode_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icon_scan [email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "icon_scan [email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Center.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "IconPickupLarge.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "icon orders.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icon [email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "icon [email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "IconBin.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ChoiceSelectorView: UIView {
textLabel.pin.top().left().before(of: segmentedControl).margin(margin).sizeToFit(.width)
} else {
// The UISegmentedControl is placed below the label.
textLabel.pin.top().left().right().margin(margin).sizeToFit(.width)
textLabel.pin.top().horizontally().margin(margin).sizeToFit(.width)
segmentedControl.pin.below(of: textLabel).right().margin(margin)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright (c) 2017 Luc Dion
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import UIKit
import PinLayout

class SafeAreaCornersView: UIView {
fileprivate let safeAreaZoneView = UIView()

fileprivate let centerImageView = UIImageView(image: UIImage(named: "Center")!)

// Corners
fileprivate let topLeftImageView = UIImageView(image: UIImage(named: "ArrowCorner")!)
fileprivate let topRightImageView = UIImageView(image: UIImage(named: "ArrowCorner")!)
fileprivate let bottomRightImageView = UIImageView(image: UIImage(named: "ArrowCorner")!)
fileprivate let bottomLeftImageView = UIImageView(image: UIImage(named: "ArrowCorner")!)

// Edges
fileprivate let topImageView = UIImageView(image: UIImage(named: "Arrow")!)
fileprivate let rightImageView = UIImageView(image: UIImage(named: "Arrow")!)
fileprivate let bottomImageView = UIImageView(image: UIImage(named: "Arrow")!)
fileprivate let leftImageView = UIImageView(image: UIImage(named: "Arrow")!)

init() {
super.init(frame: .zero)
backgroundColor = .white

safeAreaZoneView.backgroundColor = UIColor.black.withAlphaComponent(0.2)
addSubview(safeAreaZoneView)

addSubview(centerImageView)

addSubview(topLeftImageView)
topRightImageView.transform = .init(rotationAngle: CGFloat.pi / 2)
addSubview(topRightImageView)
bottomRightImageView.transform = .init(rotationAngle: CGFloat.pi)
addSubview(bottomRightImageView)
bottomLeftImageView.transform = .init(rotationAngle: CGFloat.pi * 3 / 2)
addSubview(bottomLeftImageView)

addSubview(topImageView)
rightImageView.transform = .init(rotationAngle: CGFloat.pi / 2)
addSubview(rightImageView)
bottomImageView.transform = .init(rotationAngle: CGFloat.pi)
addSubview(bottomImageView)
leftImageView.transform = .init(rotationAngle: CGFloat.pi * 3 / 2)
addSubview(leftImageView)
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}

override func safeAreaInsetsDidChange() {
if #available(iOS 11.0, *) {
super.safeAreaInsetsDidChange()
}
}

override func layoutSubviews() {
super.layoutSubviews()

safeAreaZoneView.pin.all(pin.safeArea)

centerImageView.pin.center().size(40)

topRightImageView.pin.top(pin.safeArea).right(pin.safeArea).size(40)
topLeftImageView.pin.top(pin.safeArea).left(pin.safeArea).size(40)
bottomRightImageView.pin.bottom(pin.safeArea).right(pin.safeArea).size(40)
bottomLeftImageView.pin.bottom(pin.safeArea).left(pin.safeArea).size(40)

topImageView.pin.top(pin.safeArea).hCenter().size(40)
rightImageView.pin.right(pin.safeArea).vCenter().size(40)
bottomImageView.pin.bottom(pin.safeArea).hCenter().size(40)
leftImageView.pin.left(pin.safeArea).vCenter().size(40)
}
}
Loading

0 comments on commit e5334c2

Please sign in to comment.