Skip to content

Commit

Permalink
第12天-升级到swift4
Browse files Browse the repository at this point in the history
  • Loading branch information
qianyb committed Dec 24, 2018
1 parent 76b2616 commit 244ffb5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
TargetAttributes = {
9F3F2CBE1C4BFE7200193399 = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = F3YT8BWBYJ;
};
9F3F2CD21C4BFE7300193399 = {
CreatedOnToolsVersion = 7.2;
Expand Down Expand Up @@ -401,21 +402,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = LoginAnimation/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.appkitchen.LoginAnimation;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
9F3F2CE91C4BFE7300193399 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = LoginAnimation/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = me.appkitchen.LoginAnimation;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
16 changes: 7 additions & 9 deletions Project 12 - LoginAnimation/LoginAnimation/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,30 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
return true
}

func applicationWillResignActive(application: UIApplication) {
private func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class SplasViewController: UIViewController {

}

override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
override var preferredStatusBarStyle: UIStatusBarStyle {
return UIStatusBarStyle.lightContent
}

}
35 changes: 21 additions & 14 deletions Project 12 - LoginAnimation/LoginAnimation/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import UIKit

class ViewController: UIViewController {

@IBAction func backButtonDidTouch(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: nil)
@IBAction func backButtonDidTouch(_ sender: AnyObject) {
self.dismiss(animated: true, completion: nil)
}

@IBOutlet weak var uesernameTextField: UITextField!
Expand All @@ -27,19 +27,21 @@ class ViewController: UIViewController {

uesernameTextField.layer.cornerRadius = 5
passwordTextField.layer.cornerRadius = 5
uesernameTextField.delegate = self
passwordTextField.delegate = self
loginButton.layer.cornerRadius = 5

}

override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
override var preferredStatusBarStyle : UIStatusBarStyle {
return UIStatusBarStyle.lightContent
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

centerAlignUsername.constant -= view.bounds.width
Expand All @@ -48,44 +50,49 @@ class ViewController: UIViewController {

}

override func viewDidAppear(animated: Bool) {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

UIView.animateWithDuration(0.5, delay: 0.00, options: UIViewAnimationOptions.CurveEaseOut, animations: {
UIView.animate(withDuration: 0.5, delay: 0.00, options: .curveEaseOut, animations: {

self.centerAlignUsername.constant += self.view.bounds.width
self.view.layoutIfNeeded()

}, completion: nil)

UIView.animateWithDuration(0.5, delay: 0.10, options: .CurveEaseOut, animations: {
UIView.animate(withDuration: 0.5, delay: 0.10, options: .curveEaseOut, animations: {

self.centerAlignPassword.constant += self.view.bounds.width
self.view.layoutIfNeeded()

}, completion: nil)

UIView.animateWithDuration(0.5, delay: 0.20, options: .CurveEaseOut, animations: {
UIView.animate(withDuration: 0.5, delay: 0.20, options: .curveEaseOut, animations: {

self.loginButton.alpha = 1

}, completion: nil)

}

@IBAction func loginButtonDidTouch(sender: UIButton) {
@IBAction func loginButtonDidTouch(_ sender: UIButton) {

let bounds = self.loginButton.bounds

//Animate
UIView.animateWithDuration(1.0, delay: 0.0, usingSpringWithDamping: 0.2, initialSpringVelocity: 10, options: UIViewAnimationOptions.CurveLinear, animations: {
UIView.animate(withDuration: 1.0, delay: 0.0, usingSpringWithDamping: 0.2, initialSpringVelocity: 10, options: .curveLinear, animations: {

self.loginButton.bounds = CGRect(x: bounds.origin.x - 20, y: bounds.origin.y, width: bounds.size.width + 60, height: bounds.size.height)
self.loginButton.enabled = false
self.loginButton.isEnabled = false

}, completion: { finished in self.loginButton.enabled = true })

}, completion: { finished in self.loginButton.isEnabled = true })
}

}

extension ViewController : UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
return textField.resignFirstResponder()
}
}

0 comments on commit 244ffb5

Please sign in to comment.