Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
Fix widthConstraint/heightConstraint
Browse files Browse the repository at this point in the history
  • Loading branch information
davdroman committed Jan 13, 2016
1 parent 688462d commit c9826a4
Show file tree
Hide file tree
Showing 45 changed files with 37 additions and 31 deletions.
Empty file modified Assets/1.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Assets/header.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified LICENSE
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions Popsicle.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -412,7 +412,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Empty file modified Popsicle.xcodeproj/project.xcworkspace/contents.xcworkspacedata
100644 → 100755
Empty file.
Empty file modified Popsicle.xcodeproj/xcshareddata/xcschemes/Popsicle.xcscheme
100644 → 100755
Empty file.
Empty file modified Popsicle/EasingFunction.swift
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Popsicle/Info.plist
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Empty file modified Popsicle/Interpolable.swift
100644 → 100755
Empty file.
Empty file modified Popsicle/Interpolation.swift
100644 → 100755
Empty file.
7 changes: 7 additions & 0 deletions Popsicle/Interpolator.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ public class Interpolator {
public var time: Time = 0 {
didSet {
for interpolation in self.interpolations {
if let interpolation = interpolation as? Interpolation<CGFloat> {
if interpolation.keyPath == "constant" && (interpolation.object as? NSLayoutConstraint)?.firstAttribute == .Width {
print((interpolation.object as? NSLayoutConstraint))
print((interpolation.originalObject as? UIView)?.constraints)
//(interpolation.originalObject as? UIView)?.layoutIfNeeded()
}
}
interpolation.setTime(self.time)
}
}
Expand Down
14 changes: 9 additions & 5 deletions Popsicle/KeyPath.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ public let heightConstraint = KeyPath<UIView, CGFloat>(keyPathable
extension NSObject {
static func filteredObjectAndKeyPath<T: NSObject, U: Interpolable>(withObject object: T, andKeyPath keyPath: KeyPath<T, U>) -> (NSObject, String) {
if let view = object as? UIView, let superview = view.superview, let attribute = keyPath.keyPathable as? NSLayoutAttribute {
for constraint in superview.constraints where
(constraint.firstItem as? NSObject == view && constraint.firstAttribute == attribute) ||
(constraint.secondItem as? NSObject == view && constraint.secondAttribute == attribute) {
return (constraint, constant.keyPathable.stringify())
}

let constrainedView = (attribute == .Width || attribute == .Height) ? view : superview

for constraint in constrainedView.constraints where
!constraint.isKindOfClass(NSClassFromString("NSContentSizeLayoutConstraint")!) &&
((constraint.firstItem as? NSObject == view && constraint.firstAttribute == attribute) ||
(constraint.secondItem as? NSObject == view && constraint.secondAttribute == attribute)) {
return (constraint, constant.keyPathable.stringify())
}
}

return (object, keyPath.keyPathable.stringify())
Expand Down
Empty file modified Popsicle/Popsicle.h
100644 → 100755
Empty file.
Empty file modified PopsicleDemo/AppDelegate.swift
100644 → 100755
Empty file.
20 changes: 13 additions & 7 deletions PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Contents.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@2x.png",
"filename" : "Icon-29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@3x.png",
"filename" : "Icon-29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "[email protected]",
"filename" : "Icon-40@2x-1.png",
"scale" : "2x"
},
{
Expand All @@ -39,25 +39,25 @@
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-Small~iPad.png",
"filename" : "Icon-29.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-Small~iPad@2x.png",
"filename" : "Icon-29@2x-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-40~iPad.png",
"filename" : "Icon-40.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-40~iPad@2x.png",
"filename" : "[email protected]",
"scale" : "2x"
},
{
Expand All @@ -71,6 +71,12 @@
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "[email protected]",
"scale" : "2x"
}
],
"info" : {
Expand Down
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.
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.
Binary file modified PopsicleDemo/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file modified PopsicleDemo/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PopsicleDemo/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified PopsicleDemo/Assets.xcassets/AppIcon.appiconset/[email protected]
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file modified PopsicleDemo/Assets.xcassets/Contents.json
100644 → 100755
Empty file.
Empty file modified PopsicleDemo/Assets.xcassets/logo.imageset/Contents.json
100644 → 100755
Empty file.
Empty file modified PopsicleDemo/Assets.xcassets/logo.imageset/logo.pdf
100644 → 100755
Empty file.
5 changes: 2 additions & 3 deletions PopsicleDemo/Base.lproj/LaunchScreen.storyboard
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -16,7 +16,6 @@
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
Expand Down
2 changes: 1 addition & 1 deletion PopsicleDemo/Info.plist
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Empty file modified PopsicleDemo/PageScrollView.swift
100644 → 100755
Empty file.
14 changes: 2 additions & 12 deletions PopsicleDemo/PageViews.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
</dependencies>
<objects>
Expand All @@ -14,21 +14,18 @@
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Welcome to this demo of Popsicle" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ecS-oi-gEe">
<rect key="frame" x="171" y="549.5" width="259.5" height="20.5"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="6y5-6A-Jqb">
<rect key="frame" x="172" y="172" width="256" height="256"/>
<animations/>
<constraints>
<constraint firstAttribute="width" constant="256" id="HP8-Kb-mIE"/>
<constraint firstAttribute="height" constant="256" id="xDP-1k-OEj"/>
</constraints>
</imageView>
</subviews>
<animations/>
<constraints>
<constraint firstItem="ecS-oi-gEe" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="iN0-l3-epB" secondAttribute="leading" constant="30" id="4JZ-tg-q2N"/>
<constraint firstAttribute="centerX" secondItem="ecS-oi-gEe" secondAttribute="centerX" id="LIr-Vw-5cn"/>
Expand All @@ -48,7 +45,6 @@
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iib-Tg-Cyj">
<rect key="frame" x="44" y="179.5" width="512" height="81.5"/>
<animations/>
<string key="text">That was smooth!

As you can see, Popsicle provides a great way to create transitions through value interpolations.</string>
Expand All @@ -57,7 +53,6 @@ As you can see, Popsicle provides a great way to create transitions through valu
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<constraints>
<constraint firstAttribute="centerX" secondItem="iib-Tg-Cyj" secondAttribute="centerX" id="HG8-QR-See"/>
<constraint firstItem="iib-Tg-Cyj" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="I3K-66-IeR" secondAttribute="leading" constant="30" id="JPf-6l-Scg"/>
Expand All @@ -74,7 +69,6 @@ As you can see, Popsicle provides a great way to create transitions through valu
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ijd-gD-Pdk">
<rect key="frame" x="36" y="239" width="528.5" height="61"/>
<animations/>
<string key="text">Interpolations are not bound to UIKit values, although Popsicle offers built-in support for widely used types such CGFloat, CGAffineTransform and UIColor.</string>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
Expand All @@ -87,7 +81,6 @@ As you can see, Popsicle provides a great way to create transitions through valu
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yOi-JI-a0I">
<rect key="frame" x="30" y="350" width="540.5" height="41"/>
<animations/>
<string key="text">In addition to that, Popsicle takes advantage of Swift's best features such as generics and subscripts, making it really sweet to use.</string>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
Expand All @@ -99,7 +92,6 @@ As you can see, Popsicle provides a great way to create transitions through valu
</userDefinedRuntimeAttributes>
</label>
</subviews>
<animations/>
<constraints>
<constraint firstItem="yOi-JI-a0I" firstAttribute="top" secondItem="lSl-j6-h40" secondAttribute="centerY" constant="50" id="5xz-In-fDV"/>
<constraint firstItem="yOi-JI-a0I" firstAttribute="centerX" secondItem="lSl-j6-h40" secondAttribute="centerX" id="6Nq-hu-RdY"/>
Expand All @@ -120,13 +112,11 @@ As you can see, Popsicle provides a great way to create transitions through valu
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="For requests, comments or concerns, just open a GitHub issue or ping me @DavdRoman." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4nl-Ho-8yk">
<rect key="frame" x="31" y="280" width="538.5" height="41"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<animations/>
<constraints>
<constraint firstAttribute="centerX" secondItem="4nl-Ho-8yk" secondAttribute="centerX" id="I9N-AY-ig8"/>
<constraint firstAttribute="centerY" secondItem="4nl-Ho-8yk" secondAttribute="centerY" id="T0O-jF-phJ"/>
Expand Down
Empty file modified PopsicleDemo/PopsicleDemo-Bridging-Header.h
100644 → 100755
Empty file.
Empty file modified PopsicleDemo/UIView+Utils.swift
100644 → 100755
Empty file.
Empty file modified PopsicleDemo/ViewController.swift
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.

0 comments on commit c9826a4

Please sign in to comment.