Skip to content

Commit

Permalink
Merge commit 'c17c9ce17b216dd6d9e816d566f335383765e76f'
Browse files Browse the repository at this point in the history
  • Loading branch information
Boyce committed May 5, 2015
2 parents b135bdd + c17c9ce commit 4689b10
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 48 deletions.
2 changes: 1 addition & 1 deletion BCMagicTransition/BCMagicTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ - (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];

[toViewController.view layoutIfNeeded];
UIView *containerView = [transitionContext containerView];

if (self.isMagic) {
Expand Down
6 changes: 3 additions & 3 deletions BCMagicTransition/BCMagicTransitionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ - (void)navigationController:(UINavigationController *)navigationController didS
}

- (void)handleEdgePanGestureRecognizer:(UIScreenEdgePanGestureRecognizer*)recognizer {
CGFloat progress = [recognizer translationInView:self.view].x / (self.view.bounds.size.width * 1.0);
progress = MIN(1.0, MAX(0.0, progress));
CGFloat progress = [recognizer translationInView:self.view].x / (self.view.bounds.size.width * 0.99);
progress = MIN(0.99, MAX(0.0, progress));

if (recognizer.state == UIGestureRecognizerStateBegan) {
self.interactivePopTransition = [[UIPercentDrivenInteractiveTransition alloc] init];
Expand All @@ -143,7 +143,7 @@ - (void)handleEdgePanGestureRecognizer:(UIScreenEdgePanGestureRecognizer*)recogn

} else if (recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) {
// Finish or cancel the interactive transition
if (progress > 0.5) {
if (progress > 0.4) {
[self.interactivePopTransition finishInteractiveTransition];
} else {
[self.interactivePopTransition cancelInteractiveTransition];
Expand Down
1 change: 0 additions & 1 deletion MagicTransition/FirstViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ - (IBAction)push:(id)sender {

// preload views to the memory and get thue frames
[secondVC loadView];
[secondVC.view layoutIfNeeded];

// setup fromviews array and toviews array
NSArray *fromViews = [NSArray arrayWithObjects:self.imageView1, self.imageView2, self.label1, nil];
Expand Down
13 changes: 4 additions & 9 deletions MagicTransition/FirstViewController.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1514" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14E11f" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="FirstViewController">
Expand All @@ -14,7 +15,7 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Test Magic Move" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="13J-k1-d3Z">
Expand Down Expand Up @@ -45,17 +46,11 @@
<constraint firstAttribute="centerX" secondItem="lqW-6r-2LP" secondAttribute="centerX" id="aLz-nI-ikb"/>
<constraint firstAttribute="bottom" secondItem="lqW-6r-2LP" secondAttribute="bottom" constant="28" id="nBp-OU-O6v"/>
</constraints>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<point key="canvasLocation" x="318" y="46"/>
</view>
</objects>
<resources>
<image name="1" width="256" height="256"/>
<image name="2" width="512" height="512"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
2 changes: 1 addition & 1 deletion MagicTransition/SecondViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ - (IBAction)push:(id)sender {

// preload views to the memory
[thirdVC loadView];
[thirdVC.view layoutIfNeeded];


// setup fromviews array and toviews array
NSArray *fromViews = [NSArray arrayWithObjects:self.imageView1, self.imageView2, self.label1, nil];
Expand Down
54 changes: 35 additions & 19 deletions MagicTransition/SecondViewController.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14E11f" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SecondViewController">
Expand All @@ -14,20 +15,18 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="2" translatesAutoresizingMaskIntoConstraints="NO" id="zwO-iI-XuA">
<rect key="frame" x="3" y="102" width="213" height="207"/>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="2" translatesAutoresizingMaskIntoConstraints="NO" id="zwO-iI-XuA">
<rect key="frame" x="194" y="197" width="213" height="207"/>
<constraints>
<constraint firstAttribute="height" constant="207" id="dO4-3i-IIb"/>
<constraint firstAttribute="width" constant="213" id="qV6-O2-LMC"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Test Magic Move" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OUJ-rx-E6G">
<rect key="frame" x="135" y="81" width="131" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OFA-9G-EGr">
<rect key="frame" x="121" y="510" width="78" height="30"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OFA-9G-EGr">
<rect key="frame" x="278" y="534" width="45" height="36"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<state key="normal" title="Push">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
Expand All @@ -36,22 +35,39 @@
<action selector="push:" destination="-1" eventType="touchUpInside" id="ph9-4H-Y9c"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" image="1" translatesAutoresizingMaskIntoConstraints="NO" id="bdp-td-hgg">
<rect key="frame" x="181" y="258" width="126" height="121"/>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="1" translatesAutoresizingMaskIntoConstraints="NO" id="bdp-td-hgg">
<rect key="frame" x="361" y="472" width="102" height="98"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="102" id="Egg-55-RHV"/>
<constraint firstAttribute="width" constant="102" id="SSt-59-J88"/>
<constraint firstAttribute="height" constant="98" id="mFQ-SQ-chl"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="98" id="o4H-TI-uV9"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Test Magic Move" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OUJ-rx-E6G">
<rect key="frame" x="30" y="448" width="131" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="OUJ-rx-E6G" secondAttribute="bottom" constant="131" id="2Br-qS-3h1"/>
<constraint firstAttribute="centerX" secondItem="OFA-9G-EGr" secondAttribute="centerX" id="52A-gl-q1A"/>
<constraint firstItem="bdp-td-hgg" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="211" id="Gon-WR-xS5"/>
<constraint firstItem="bdp-td-hgg" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="141" id="HsR-l7-OTD"/>
<constraint firstAttribute="bottom" secondItem="OFA-9G-EGr" secondAttribute="bottom" constant="28" id="s77-jg-7FG"/>
<constraint firstAttribute="centerX" secondItem="zwO-iI-XuA" secondAttribute="centerX" id="Bje-DJ-5og"/>
<constraint firstAttribute="bottom" secondItem="bdp-td-hgg" secondAttribute="bottom" constant="30" id="Pnm-cb-gH7"/>
<constraint firstAttribute="centerX" secondItem="OFA-9G-EGr" secondAttribute="centerX" id="dag-TS-Q8D"/>
<constraint firstItem="OUJ-rx-E6G" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="30" id="qYm-DQ-Qbl"/>
<constraint firstAttribute="bottom" secondItem="OFA-9G-EGr" secondAttribute="bottom" constant="30" id="s77-jg-7FG"/>
<constraint firstAttribute="centerY" secondItem="zwO-iI-XuA" secondAttribute="centerY" id="uu2-Di-AkH"/>
<constraint firstItem="bdp-td-hgg" firstAttribute="leading" secondItem="OFA-9G-EGr" secondAttribute="trailing" constant="38" id="zmk-0i-OlK"/>
</constraints>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<variation key="default">
<mask key="constraints">
<exclude reference="dag-TS-Q8D"/>
</mask>
</variation>
<point key="canvasLocation" x="322" y="334"/>
</view>
</objects>
Expand Down
38 changes: 27 additions & 11 deletions MagicTransition/ThirdViewController.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1514" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14E11f" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ThirdViewController">
Expand All @@ -14,24 +15,39 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="1" translatesAutoresizingMaskIntoConstraints="NO" id="hg2-x9-hdr">
<rect key="frame" x="42" y="118" width="76" height="76"/>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="2" translatesAutoresizingMaskIntoConstraints="NO" id="Np3-Gf-CVf">
<rect key="frame" x="52" y="425" width="86" height="86"/>
<constraints>
<constraint firstAttribute="height" constant="86" id="53S-nh-Iwg"/>
<constraint firstAttribute="width" constant="86" id="HhO-Su-bey"/>
</constraints>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="2" translatesAutoresizingMaskIntoConstraints="NO" id="Np3-Gf-CVf">
<rect key="frame" x="126" y="113" width="86" height="86"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Test Magic Move" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4zu-dc-HuC">
<rect key="frame" x="63" y="207" width="131" height="21"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Test Magic Move" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4zu-dc-HuC">
<rect key="frame" x="326" y="116" width="131" height="21"/>
<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="1" translatesAutoresizingMaskIntoConstraints="NO" id="hg2-x9-hdr">
<rect key="frame" x="262" y="262" width="76" height="76"/>
<constraints>
<constraint firstAttribute="height" constant="76" id="8Wt-A3-Tul"/>
<constraint firstAttribute="width" constant="76" id="IZr-MP-IBk"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="Np3-Gf-CVf" secondAttribute="bottom" constant="89" id="3GZ-6x-HEs"/>
<constraint firstAttribute="centerX" secondItem="hg2-x9-hdr" secondAttribute="centerX" id="SWC-0K-kJw"/>
<constraint firstItem="Np3-Gf-CVf" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="52" id="YQk-ZT-hhk"/>
<constraint firstAttribute="centerY" secondItem="hg2-x9-hdr" secondAttribute="centerY" id="e8B-1m-B2i"/>
<constraint firstAttribute="trailing" secondItem="4zu-dc-HuC" secondAttribute="trailing" constant="143" id="gk2-Tq-gdL"/>
<constraint firstItem="4zu-dc-HuC" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="116" id="kUL-7j-W6c"/>
</constraints>
<point key="canvasLocation" x="335" y="121"/>
</view>
</objects>
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ import "BCMagicTransitionViewController.h"
- (void)push
{
... ...
//If you use AutoLayout, before using animation, you need to layout views so that it can get the correct frame. It means need to invoke layoutIfNeeded before pushing.
[secondVC.view layoutIfNeeded];


[self pushViewController:secondVC fromViews:fromViews toViews:toViews duration:0.3];
}

Expand Down

0 comments on commit 4689b10

Please sign in to comment.