Skip to content

Commit

Permalink
Get rid of PureLayout. Fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
ldiqual committed Oct 23, 2016
1 parent 2d5f1b4 commit 0273be4
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 107 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ xcuserdata
*.moved-aside
*.xcuserstate
*.xcscmblueprint
.DS_Store

## Obj-C/Swift specific
*.hmap
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0
2.3.1
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -15,25 +16,23 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DCF-7Z-a9u" customClass="SwiftyButton" customModule="SwiftyButton">
<rect key="frame" x="210" y="40" width="180" height="50"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="50" id="JIt-2M-lPL"/>
<constraint firstAttribute="width" constant="200" id="kYA-B2-qyN"/>
</constraints>
<state key="normal" title="Press me">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="buttonColor">
<color key="value" red="0.90588235855102539" green="0.29803922772407532" blue="0.23529411852359772" alpha="1" colorSpace="calibratedRGB"/>
<color key="value" red="0.90588235855102539" green="0.29803922772407532" blue="0.23529411852359772" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="shadowColor">
<color key="value" red="0.75294119119644165" green="0.22352941334247589" blue="0.16862745583057404" alpha="1" colorSpace="calibratedRGB"/>
<color key="value" red="0.75294119119644165" green="0.22352941334247589" blue="0.16862745583057404" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="shadowHeight">
<real key="value" value="5"/>
Expand All @@ -49,8 +48,6 @@
</variation>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0VC-Tk-Okj">
<rect key="frame" x="400" y="40" width="180" height="50"/>
<animations/>
<constraints>
<constraint firstAttribute="width" constant="200" id="bUp-Qm-6IM"/>
<constraint firstAttribute="height" constant="50" id="mNo-GQ-HZ4"/>
Expand All @@ -62,18 +59,16 @@
</variation>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0vH-Wp-tiw" customClass="SwiftyButton" customModule="SwiftyButton">
<rect key="frame" x="20" y="40" width="180" height="50"/>
<animations/>
<constraints>
<constraint firstAttribute="height" constant="50" id="KnS-bA-CKM"/>
<constraint firstAttribute="width" constant="200" id="fY5-Is-knb"/>
</constraints>
<state key="normal" title="Press me">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="buttonColor">
<color key="value" red="0.94509804248809814" green="0.76862746477127075" blue="0.058823529630899429" alpha="1" colorSpace="calibratedRGB"/>
<color key="value" red="0.94509804248809814" green="0.76862746477127075" blue="0.058823529630899429" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="shadowHeight">
<real key="value" value="0.0"/>
Expand All @@ -82,7 +77,7 @@
<real key="value" value="5"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="highlightedColor">
<color key="value" red="0.9529411792755127" green="0.61176472902297974" blue="0.070588238537311554" alpha="1" colorSpace="calibratedRGB"/>
<color key="value" red="0.9529411792755127" green="0.61176472902297974" blue="0.070588238537311554" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<variation key="default">
Expand All @@ -92,8 +87,7 @@
</variation>
</button>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="DCF-7Z-a9u" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="20" id="27a-u6-uvL"/>
<constraint firstItem="DCF-7Z-a9u" firstAttribute="leading" secondItem="0vH-Wp-tiw" secondAttribute="trailing" constant="10" id="DQa-tl-Fjc"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@ class ViewController: UIViewController {
super.viewDidLoad()

let button = SwiftyCustomContentButton()
button.translatesAutoresizingMaskIntoConstraints = false
customButtonContainerView.addSubview(button)
button.autoPinEdgesToSuperviewEdges()
customButtonContainerView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[button]|", metrics: nil, views: ["button": button]))
customButtonContainerView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[button]|", metrics: nil, views: ["button": button]))
button.buttonColor = UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1)
button.shadowColor = UIColor(red: 41/255, green: 128/255, blue: 185/255, alpha: 1)

let indicator = UIActivityIndicatorView(activityIndicatorStyle: .white)
indicator.translatesAutoresizingMaskIntoConstraints = false
button.customContentView.addSubview(indicator)
indicator.autoPinEdgesToSuperviewEdges(with: UIEdgeInsets(top: 10, left: 15, bottom: 10, right: 0), excludingEdge: .right)
button.customContentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-10-[indicator]-10-|", metrics: nil, views: ["indicator": indicator]))
indicator.startAnimating()

let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
button.customContentView.addSubview(label)
label.autoPinEdgesToSuperviewEdges(with: UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 10), excludingEdge: .left)
label.autoPinEdge(.left, to: .right, of: indicator, withOffset: 10)
button.customContentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-10-[label]-10-|", metrics: nil, views: ["label": label]))
button.customContentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-15-[indicator]-10-[label]-15-|", metrics: nil, views: ["indicator": indicator, "label": label]))
label.text = "Loading..."
label.textColor = UIColor.white

Expand All @@ -41,9 +45,6 @@ class ViewController: UIViewController {
zeroButton.cornerRadius = 0
zeroButton.highlightedColor = UIColor.blue
view.addSubview(zeroButton)
zeroButton.autoPinEdge(.top, to: .bottom, of: button, withOffset: 30)
zeroButton.autoAlignAxis(toSuperviewAxis: .vertical)
zeroButton.autoSetDimensions(to: CGSize(width: 200, height: 40))
zeroButton.setTitle("Zero Button", for: .normal)
}
}
Expand Down
6 changes: 0 additions & 6 deletions Podfile

This file was deleted.

10 changes: 0 additions & 10 deletions Podfile.lock

This file was deleted.

7 changes: 1 addition & 6 deletions SwiftyButton.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ Pod::Spec.new do |s|
s.author = { "Scoop" => "[email protected]" }

s.source = { :git => "https://github.com/TakeScoop/SwiftyButton.git", :tag => s.version }
s.source_files = "SwiftyButton/SwiftyButton.swift", "SwiftyButton/SwiftyButton+ResizableImage.swift"
s.source_files = "SwiftyButton/*.swift"
s.framework = "UIKit"

s.requires_arc = true
s.platform = :ios, "8.0"

s.subspec 'CustomContent' do |sp|
sp.source_files = "SwiftyButton/*.swift"
sp.dependency 'PureLayout', '~> 3.0'
end
end
51 changes: 0 additions & 51 deletions SwiftyButton.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
objects = {

/* Begin PBXBuildFile section */
65FDF09739ACFE572F95E67B /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 812783EF6177ECF8A694BB5E /* Pods.framework */; };
C0372F2E1C0694F500E00B85 /* SwiftyCustomContentButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0372F2D1C0694F500E00B85 /* SwiftyCustomContentButton.swift */; };
C0F04E0F1BFA83F700E9925E /* SwiftyButton.h in Headers */ = {isa = PBXBuildFile; fileRef = C0F04E0E1BFA83F700E9925E /* SwiftyButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
C0F04E181BFA842B00E9925E /* SwiftyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F04E161BFA842B00E9925E /* SwiftyButton.swift */; };
C0F04E191BFA842B00E9925E /* SwiftyButton+ResizableImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F04E171BFA842B00E9925E /* SwiftyButton+ResizableImage.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
5CB52FFAE920C6E710A6A10A /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
732597CC58FF5185E850D27B /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
812783EF6177ECF8A694BB5E /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C0372F2D1C0694F500E00B85 /* SwiftyCustomContentButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyCustomContentButton.swift; sourceTree = "<group>"; };
C0F04E0B1BFA83F700E9925E /* SwiftyButton.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftyButton.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -31,7 +28,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
65FDF09739ACFE572F95E67B /* Pods.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -46,21 +42,11 @@
name = Frameworks;
sourceTree = "<group>";
};
B623975D33EE45AD9F675E18 /* Pods */ = {
isa = PBXGroup;
children = (
5CB52FFAE920C6E710A6A10A /* Pods.debug.xcconfig */,
732597CC58FF5185E850D27B /* Pods.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
C0F04E011BFA83F700E9925E = {
isa = PBXGroup;
children = (
C0F04E0D1BFA83F700E9925E /* SwiftyButton */,
C0F04E0C1BFA83F700E9925E /* Products */,
B623975D33EE45AD9F675E18 /* Pods */,
30A2B1221A3581DFF7D1206B /* Frameworks */,
);
sourceTree = "<group>";
Expand Down Expand Up @@ -103,12 +89,10 @@
isa = PBXNativeTarget;
buildConfigurationList = C0F04E131BFA83F700E9925E /* Build configuration list for PBXNativeTarget "SwiftyButton" */;
buildPhases = (
58AEE54A3B5077B862919504 /* Check Pods Manifest.lock */,
C0F04E061BFA83F700E9925E /* Sources */,
C0F04E071BFA83F700E9925E /* Frameworks */,
C0F04E081BFA83F700E9925E /* Headers */,
C0F04E091BFA83F700E9925E /* Resources */,
76CBCDCFD9B69BDA1C866BA9 /* Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -161,39 +145,6 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
58AEE54A3B5077B862919504 /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
76CBCDCFD9B69BDA1C866BA9 /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
C0F04E061BFA83F700E9925E /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -301,7 +252,6 @@
};
C0F04E141BFA83F700E9925E /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 5CB52FFAE920C6E710A6A10A /* Pods.debug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
Expand All @@ -321,7 +271,6 @@
};
C0F04E151BFA83F700E9925E /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 732597CC58FF5185E850D27B /* Pods.release.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
Expand Down
3 changes: 0 additions & 3 deletions SwiftyButton.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions SwiftyButton/SwiftyCustomContentButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import Foundation
import PureLayout

open class SwiftyCustomContentButton: SwiftyButton {

Expand All @@ -33,10 +32,9 @@ open class SwiftyCustomContentButton: SwiftyButton {
override func configure() {
super.configure()

customContentView.translatesAutoresizingMaskIntoConstraints = false
addSubview(customContentView)
customContentViewTopConstraint = customContentView.autoPinEdge(toSuperviewEdge: .top)
customContentViewBottomConstraint = customContentView.autoPinEdge(toSuperviewEdge: .bottom)
customContentView.autoPinEdge(toSuperviewEdge: .left)
customContentView.autoPinEdge(toSuperviewEdge: .right)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[contentView]|", options: [], metrics: nil, views: ["contentView": customContentView]))
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[contentView]|", options: [], metrics: nil, views: ["contentView": customContentView]))
}
}

0 comments on commit 0273be4

Please sign in to comment.