Skip to content

Commit b4318e3

Browse files
- swift 2.0 support
1 parent 817bef4 commit b4318e3

5 files changed

Lines changed: 24 additions & 21 deletions

File tree

Transitions/TransitionsTests/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>com.him.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

Transitions/ZoomTransitionSample-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>com.him.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

Transitions/ZoomTransitionSample.xcodeproj/project.pbxproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@
179179
6A97143D19DB815A00C9C36D /* Project object */ = {
180180
isa = PBXProject;
181181
attributes = {
182-
LastUpgradeCheck = 0600;
182+
LastSwiftMigration = 0710;
183+
LastSwiftUpdateCheck = 0710;
184+
LastUpgradeCheck = 0710;
183185
ORGANIZATIONNAME = him;
184186
TargetAttributes = {
185187
6A97145919DB815A00C9C36D = {
@@ -279,6 +281,7 @@
279281
INFOPLIST_FILE = "ZoomTransitionSample-Info.plist";
280282
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
281283
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
284+
PRODUCT_BUNDLE_IDENTIFIER = "com.him.$(PRODUCT_NAME:rfc1034identifier)";
282285
PRODUCT_NAME = ZoomTransitionSample;
283286
};
284287
name = Debug;
@@ -290,6 +293,7 @@
290293
INFOPLIST_FILE = "ZoomTransitionSample-Info.plist";
291294
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
292295
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
296+
PRODUCT_BUNDLE_IDENTIFIER = "com.him.$(PRODUCT_NAME:rfc1034identifier)";
293297
PRODUCT_NAME = ZoomTransitionSample;
294298
};
295299
name = Release;
@@ -314,6 +318,7 @@
314318
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
315319
COPY_PHASE_STRIP = NO;
316320
ENABLE_STRICT_OBJC_MSGSEND = YES;
321+
ENABLE_TESTABILITY = YES;
317322
GCC_C_LANGUAGE_STANDARD = gnu99;
318323
GCC_DYNAMIC_NO_PIC = NO;
319324
GCC_OPTIMIZATION_LEVEL = 0;
@@ -385,6 +390,7 @@
385390
);
386391
INFOPLIST_FILE = TransitionsTests/Info.plist;
387392
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
393+
PRODUCT_BUNDLE_IDENTIFIER = "com.him.$(PRODUCT_NAME:rfc1034identifier)";
388394
PRODUCT_NAME = "$(TARGET_NAME)";
389395
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Transitions.app/Transitions";
390396
};
@@ -400,6 +406,7 @@
400406
);
401407
INFOPLIST_FILE = TransitionsTests/Info.plist;
402408
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
409+
PRODUCT_BUNDLE_IDENTIFIER = "com.him.$(PRODUCT_NAME:rfc1034identifier)";
403410
PRODUCT_NAME = "$(TARGET_NAME)";
404411
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Transitions.app/Transitions";
405412
};

Transitions/ZoomTransitionSample/ImageViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class ImageViewController: UIViewController, ZoomTransitionProtocol {
3030
override func updateViewConstraints() {
3131
super.updateViewConstraints()
3232

33-
let topGuide = self.topLayoutGuide;
34-
let views = ["_imageView": imageView, "topGuide": topGuide]
33+
// let topGuide = self.topLayoutGuide;
34+
// let views = ["_imageView": imageView, "topGuide": topGuide]
3535
// let constraint:[AnyObject]! = NSLayoutConstraint.constraintsWithVisualFormat("V:[topGuide][_imageView]", options: NSLayoutFormatOptions.allZeros, metrics: nil, views: views)
3636
// self.view.addConstraints(constraint)
3737
}

ZoomTransition/ZoomTransition.swift

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
3737

3838
// MARK: - UIViewControllerAnimatedTransition Protocol
3939

40-
public func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval {
40+
public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
4141
if interactive {
4242
return 0.7
4343
}
@@ -63,21 +63,21 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
6363

6464
assert(fromView != nil && toView != nil, "fromView and toView need to be set")
6565

66-
var container = self.transitionContext!.containerView();
66+
let container = self.transitionContext!.containerView();
6767

6868
// add toViewController to Transition Container
6969
if let view = toViewController?.view {
7070
if (isPresenting){
71-
container.addSubview(view)
71+
container?.addSubview(view)
7272
} else {
73-
container.insertSubview(view, belowSubview: fromViewController!.view)
73+
container?.insertSubview(view, belowSubview: fromViewController!.view)
7474
}
7575
}
7676
toViewController?.view.layoutIfNeeded()
7777

7878
// Calculate animation frames within container view
79-
fromFrame = container.convertRect(fromView!.bounds, fromView: fromView)
80-
toFrame = container.convertRect(toView!.bounds, fromView: toView)
79+
fromFrame = container?.convertRect(fromView!.bounds, fromView: fromView)
80+
toFrame = container?.convertRect(toView!.bounds, fromView: toView)
8181

8282
// Create a copy of the fromView and add it to the Transition Container
8383
if let imageView = fromView as? UIImageView {
@@ -90,7 +90,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
9090
view.clipsToBounds = true
9191
view.frame = fromFrame!
9292
view.contentMode = fromView!.contentMode
93-
container.addSubview(view)
93+
container?.addSubview(view)
9494
}
9595

9696
if (isPresenting){
@@ -124,7 +124,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
124124
toView?.hidden = true
125125
fromView?.alpha = 0;
126126

127-
var duration = transitionDuration(transitionContext!)
127+
let duration = transitionDuration(transitionContext!)
128128
UIView.animateWithDuration(duration, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: UIViewAnimationOptions.CurveLinear, animations: { () -> Void in
129129

130130
self.toViewController?.view.alpha = 1
@@ -158,7 +158,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
158158
fromView?.alpha = 0;
159159
let duration = transitionDuration(transitionContext!)
160160

161-
UIView.animateWithDuration(duration, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: nil, animations: { () -> Void in
161+
UIView.animateWithDuration(duration, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: { () -> Void in
162162
self.fromViewController?.view.alpha = 0
163163
if (self.interactive == false){
164164
self.transitionView?.frame = self.toFrame!
@@ -192,8 +192,6 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
192192
// MARK: - Gesture Recognizer Handlers
193193

194194
func handlePinchGesture(gesture: UIPinchGestureRecognizer){
195-
var view = gesture.view!
196-
197195
switch (gesture.state) {
198196
case .Began:
199197
interactive = true;
@@ -231,7 +229,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
231229
// calculate current scale of transitionView
232230
let finalScale = animationFrame!.width / self.fromFrame!.size.width
233231
let currentScale = (transitionView!.frame.size.width / self.fromFrame!.size.width)
234-
var delta = finalScale - currentScale
232+
let delta = finalScale - currentScale
235233
var normalizedVelocity = gesture.velocity / delta
236234

237235
// add upper and lower bound on normalized velocity
@@ -249,7 +247,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
249247

250248
let duration = transitionDuration(transitionContext!)
251249

252-
UIView.animateWithDuration(duration, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: normalizedVelocity, options: UIViewAnimationOptions.allZeros, animations: { () -> Void in
250+
UIView.animateWithDuration(duration, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: normalizedVelocity, options: UIViewAnimationOptions(), animations: { () -> Void in
253251

254252
// set a new transform to reset the rotation to 0 but maintain the current scale
255253
self.transitionView?.transform = CGAffineTransformMakeScale(currentScale, currentScale)
@@ -271,8 +269,6 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
271269
}
272270

273271
func handleRotationGesture(gesture: UIRotationGestureRecognizer){
274-
var view = gesture.view!
275-
276272
if interactive {
277273
if gesture.state == UIGestureRecognizerState.Changed {
278274
transitionView!.transform = CGAffineTransformRotate(transitionView!.transform, gesture.rotation)
@@ -282,7 +278,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
282278
}
283279

284280
func handlePanGesture(gesture: UIPanGestureRecognizer){
285-
var view = gesture.view!
281+
let view = gesture.view!
286282

287283
if interactive {
288284
if gesture.state == UIGestureRecognizerState.Changed {

0 commit comments

Comments
 (0)