Skip to content

Commit

Permalink
swift 2.2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrank64 committed Jul 30, 2016
1 parent c06ff94 commit 75e1e56
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
19 changes: 10 additions & 9 deletions TFSwipeShrink/TFSwipeShrink.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@
6B388A631A92F781003D2138 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0630;
LastSwiftMigration = 0730;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
ORGANIZATIONNAME = "Taylor Franklin";
TargetAttributes = {
6B388A6A1A92F781003D2138 = {
Expand Down Expand Up @@ -289,6 +291,7 @@
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -356,6 +359,7 @@
INFOPLIST_FILE = TFSwipeShrink/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.taylorfranklin.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -367,6 +371,7 @@
INFOPLIST_FILE = TFSwipeShrink/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.taylorfranklin.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand All @@ -375,16 +380,14 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
FRAMEWORK_SEARCH_PATHS = "";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = TFSwipeShrinkTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.taylorfranklin.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TFSwipeShrink.app/TFSwipeShrink";
};
Expand All @@ -394,12 +397,10 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
FRAMEWORK_SEARCH_PATHS = "";
INFOPLIST_FILE = TFSwipeShrinkTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.taylorfranklin.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TFSwipeShrink.app/TFSwipeShrink";
};
Expand Down
2 changes: 1 addition & 1 deletion TFSwipeShrink/TFSwipeShrink/ExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ExampleViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
var path = NSBundle.mainBundle().pathForResource("bayw-HD", ofType: "mp4")
let path = NSBundle.mainBundle().pathForResource("bayw-HD", ofType: "mp4")
moviePlayerController = MPMoviePlayerViewController(contentURL: NSURL.fileURLWithPath(path!))
moviePlayerController.moviePlayer.controlStyle = MPMovieControlStyle.None
moviePlayerController.moviePlayer.scalingMode = MPMovieScalingMode.AspectFit
Expand Down
2 changes: 1 addition & 1 deletion TFSwipeShrink/TFSwipeShrink/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.taylorfranklin.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
22 changes: 11 additions & 11 deletions TFSwipeShrink/TFSwipeShrink/TFSwipeShrinkView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ class TFSwipeShrinkView: UIView, UIGestureRecognizerDelegate {
}

// Should be called when creating view from storyboard
required init(coder aDecoder: NSCoder) {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initGestures()
}

func initGestures() {

var panGesture = UIPanGestureRecognizer(target: self, action: "panning:")
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(TFSwipeShrinkView.panning(_:)))
panGesture.minimumNumberOfTouches = 1
panGesture.maximumNumberOfTouches = 1
self.addGestureRecognizer(panGesture)

var tapGesture = UITapGestureRecognizer(target: self, action: "tapped:")
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(TFSwipeShrinkView.tapped(_:)))
tapGesture.numberOfTapsRequired = 1
self.addGestureRecognizer(tapGesture)
tapGesture.delegate = self
Expand All @@ -63,10 +63,10 @@ class TFSwipeShrinkView: UIView, UIGestureRecognizerDelegate {
}

func panning(panGesture: UIPanGestureRecognizer) {
var translatedPoint = panGesture.translationInView(self.superview!)
let translatedPoint = panGesture.translationInView(self.superview!)
var gestureState = panGesture.state

var yChange = panGesture.view!.center.y + translatedPoint.y
let yChange = panGesture.view!.center.y + translatedPoint.y
if yChange < initialCenter?.y {
gestureState = UIGestureRecognizerState.Ended

Expand All @@ -78,23 +78,23 @@ class TFSwipeShrinkView: UIView, UIGestureRecognizerDelegate {
if gestureState == UIGestureRecognizerState.Began || gestureState == UIGestureRecognizerState.Changed {

// modify size as view is panned down
var progress = ((panGesture.view!.center.y - initialCenter!.y) / rangeTotal)
let progress = ((panGesture.view!.center.y - initialCenter!.y) / rangeTotal)

var invertedProgress = 1 - progress
var newWidth = finalSize!.width + (widthRange * invertedProgress)
let invertedProgress = 1 - progress
let newWidth = finalSize!.width + (widthRange * invertedProgress)

panGesture.view?.frame.size = CGSizeMake(newWidth, newWidth * aspectRatio)

// ensure center x value moves along with size change
var finalX = initialCenter!.x + (centerXRange * progress)
let finalX = initialCenter!.x + (centerXRange * progress)

panGesture.view?.center = CGPointMake(finalX, panGesture.view!.center.y + translatedPoint.y)
panGesture.setTranslation(CGPointMake(0, 0), inView: self.superview)

} else if gestureState == UIGestureRecognizerState.Ended {

var topDistance = yChange - initialCenter!.y
var bottomDistance = finalCenter!.y - yChange
let topDistance = yChange - initialCenter!.y
let bottomDistance = finalCenter!.y - yChange

var chosenCenter: CGPoint = CGPointZero
var chosenSize: CGSize = CGSizeZero
Expand Down
2 changes: 1 addition & 1 deletion TFSwipeShrink/TFSwipeShrinkTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.taylorfranklin.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down

0 comments on commit 75e1e56

Please sign in to comment.