Skip to content

Commit

Permalink
第25天—几种动画效果
Browse files Browse the repository at this point in the history
  • Loading branch information
qianyb committed Dec 27, 2018
1 parent 7593514 commit 2f8c3ec
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 366 deletions.

Large diffs are not rendered by default.

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>
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


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

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) {
// 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) {
// 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) {
// 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) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ class ColorViewController: UIViewController {
super.didReceiveMemoryWarning()
}

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


UIView.animateWithDuration(0.5, delay: 0.2, options: .CurveEaseIn, animations: { () -> Void in

self.bgColorView.backgroundColor = UIColor.blackColor()
UIView.animate(withDuration: 0.5, delay: 0.2, options: .curveEaseIn, animations: {
self.bgColorView.backgroundColor = .black

}, completion: nil )

UIView.animateWithDuration(0.5, delay: 0.8, options: .CurveEaseOut, animations: { () -> Void in

UIView.animate(withDuration: 0.5, delay: 0.8, options: .curveEaseOut, animations: {
self.numberLabel.textColor = UIColor(red:0.959, green:0.937, blue:0.109, alpha:1)

}, completion: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ class OpacityViewController: UIViewController {
super.didReceiveMemoryWarning()
}

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

UIView.animateWithDuration(2, animations: {

UIView.animate(withDuration: 2) {
self.exampleImageView.alpha = 0

})
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,25 @@ class PositionViewController: UIViewController {
super.didReceiveMemoryWarning()
}

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

UIView.animateWithDuration(0.8, delay: 0.2, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.8, options: .CurveEaseInOut, animations: { () -> Void in

UIView.animate(withDuration: 0.8, delay: 0.2, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.8, options: .curveEaseInOut, animations: {
self.yellowSquareView.center.x = self.view.bounds.width - self.yellowSquareView.center.x
self.yellowSquareView.center.y = self.yellowSquareView.center.y + 30
self.blueSquareView.center.x = self.view.bounds.width - self.blueSquareView.center.x
self.blueSquareView.center.y = self.blueSquareView.center.y + 30

}, completion: nil )

UIView.animateWithDuration(0.6, delay: 0.4, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.8, options: .CurveEaseOut, animations: { () -> Void in

UIView.animate(withDuration: 0.6, delay: 0.4, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.8, options: .curveEaseOut, animations: {
self.setHeight(180)
self.mouseView.center.y = self.view.bounds.height - self.mouseView.center.y

}, completion: nil )

}

func setHeight(height: CGFloat) {
func setHeight(_ height: CGFloat) {

var frame: CGRect = self.mouseView.frame
frame.size.height = height
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,23 @@ class RotationViewController: UIViewController {

func spin() {

UIView.animateWithDuration(0.8, delay: 0, options: .CurveLinear, animations: {

self.rotationImageView.transform = CGAffineTransformRotate(self.rotationImageView.transform, CGFloat(M_PI))
self.trump2.transform = CGAffineTransformRotate(self.trump2.transform, CGFloat(M_PI))
self.trump3.transform = CGAffineTransformRotate(self.trump3.transform, CGFloat(M_PI))
self.trump4.transform = CGAffineTransformRotate(self.trump4.transform, CGFloat(M_PI))
self.trump5.transform = CGAffineTransformRotate(self.trump5.transform, CGFloat(M_PI))
self.trump6.transform = CGAffineTransformRotate(self.trump6.transform, CGFloat(M_PI))
self.trump7.transform = CGAffineTransformRotate(self.trump7.transform, CGFloat(M_PI))
self.trump8.transform = CGAffineTransformRotate(self.trump8.transform, CGFloat(M_PI))
self.emojiLabel.transform = CGAffineTransformRotate(self.emojiLabel.transform, CGFloat(M_PI))

UIView.animate(withDuration: 0.8, delay: 0, options: .curveLinear, animations: {
self.rotationImageView.transform = self.rotationImageView.transform.rotated(by: CGFloat(Double.pi))
self.trump2.transform = self.trump2.transform.rotated(by: CGFloat(Double.pi))
self.trump3.transform = self.trump3.transform.rotated(by: CGFloat(Double.pi))
self.trump4.transform = self.trump4.transform.rotated(by: CGFloat(Double.pi))
self.trump5.transform = self.trump5.transform.rotated(by: CGFloat(Double.pi))
self.trump6.transform = self.trump6.transform.rotated(by: CGFloat(Double.pi))
self.trump7.transform = self.trump7.transform.rotated(by: CGFloat(Double.pi))
self.trump8.transform = self.trump8.transform.rotated(by: CGFloat(Double.pi))
self.emojiLabel.transform = self.emojiLabel.transform.rotated(by: CGFloat(Double.pi))
}) { (finished) -> Void in
self.spin()
}

}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ class ScaleViewController: UIViewController {
super.didReceiveMemoryWarning()
}

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


UIView.animateWithDuration(0.8, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: .CurveEaseIn, animations: { () -> Void in

self.scaleImageView.transform = CGAffineTransformMakeScale(2, 2)
UIView.animate(withDuration: 0.8, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: .curveEaseIn, animations: {
self.scaleImageView.transform = CGAffineTransform(scaleX: 2, y: 2)
self.scaleImageView.alpha = 1

}, completion: nil )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()

self.tableView.tableFooterView = UIView(frame: CGRectZero)
self.tableView.tableFooterView = UIView(frame: .zero)

}

Expand Down

0 comments on commit 2f8c3ec

Please sign in to comment.