Skip to content

Commit

Permalink
第27天— TabBar app
Browse files Browse the repository at this point in the history
  • Loading branch information
qianyb committed Dec 27, 2018
1 parent 2f8c3ec commit 0bc7583
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 383 deletions.
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>
224 changes: 29 additions & 195 deletions Project 27 - TabbarApp/TabbarApp.xcodeproj/project.pbxproj

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>
45 changes: 8 additions & 37 deletions Project 27 - TabbarApp/TabbarApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,19 @@ 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.

UITabBar.appearance().barTintColor = UIColor.whiteColor()
UITabBar.appearance().tintColor = UIColor.blackColor()
UINavigationBar.appearance().barTintColor = UIColor.blackColor()
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]

UIStatusBarStyle.LightContent

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UITabBar.appearance().barTintColor = .white
UITabBar.appearance().tintColor = .black
UINavigationBar.appearance().barTintColor = .black
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]

return true
}

func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}

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.
return UIStatusBarStyle.lightContent
}

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:.
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ArticleTableViewCell: UITableViewCell {

}

override func setSelected(selected: Bool, animated: Bool) {
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)

// Configure the view for the selected state
Expand Down
109 changes: 39 additions & 70 deletions Project 27 - TabbarApp/TabbarApp/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

29 changes: 13 additions & 16 deletions Project 27 - TabbarApp/TabbarApp/FirstTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ class FirstTabViewController: UIViewController, UITableViewDataSource, UITableVi

articleTableView.dataSource = self
articleTableView.delegate = self
articleTableView.separatorStyle = UITableViewCellSeparatorStyle.None
articleTableView.tableFooterView = UIView(frame: CGRectZero)
articleTableView.separatorStyle = UITableViewCell.SeparatorStyle.none
articleTableView.tableFooterView = UIView(frame: .zero)

}

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

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

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

animateTable()

Expand All @@ -55,15 +55,15 @@ class FirstTabViewController: UIViewController, UITableViewDataSource, UITableVi

for i in cells {
let cell: UITableViewCell = i as UITableViewCell
cell.transform = CGAffineTransformMakeTranslation(0, tableHeight)
cell.transform = CGAffineTransform(translationX: 0, y: tableHeight)
}

var index = 0

for a in cells {
let cell: UITableViewCell = a as UITableViewCell
UIView.animateWithDuration(1.0, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: {
cell.transform = CGAffineTransformMakeTranslation(0, 0);
UIView.animate(withDuration: 1.0, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: {
cell.transform = CGAffineTransform(translationX: 0, y: 0);
}, completion: nil)

index += 1
Expand All @@ -75,18 +75,16 @@ class FirstTabViewController: UIViewController, UITableViewDataSource, UITableVi
return 10
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 165
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell = articleTableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! ArticleTableViewCell

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = articleTableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! ArticleTableViewCell
let article = data[indexPath.row]

cell.avatarImage.image = UIImage(named: article.avatarImage)
Expand All @@ -96,8 +94,7 @@ class FirstTabViewController: UIViewController, UITableViewDataSource, UITableVi
cell.articleTitleLabel.text = article.articleTitle
cell.articleSouceLabel.text = article.articleSouce
cell.articelCreatedAtLabel.text = article.articleTime

cell.selectionStyle = UITableViewCellSelectionStyle.None
cell.selectionStyle = UITableViewCell.SelectionStyle.none

return cell

Expand Down
34 changes: 15 additions & 19 deletions Project 27 - TabbarApp/TabbarApp/SecondTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,36 @@ class SecondTabViewController: UIViewController {
@IBOutlet weak var exploreImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()

self.exploreImageView.alpha = 0
self.exploreImageView.transform = CGAffineTransformMakeScale(0.5, 0.5)
resetViewTransform()
}

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

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

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

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

self.exploreImageView.transform = CGAffineTransformMakeScale(1, 1)
UIView.animate(withDuration: 0.5, delay: 0.1, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: .curveEaseIn, animations: {
self.exploreImageView.transform = CGAffineTransform(scaleX: 1, y: 1)
self.exploreImageView.alpha = 1

}, completion: nil )
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
resetViewTransform()
}

// MARK:
func resetViewTransform() {
self.exploreImageView.alpha = 0
self.exploreImageView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
}
*/

}
36 changes: 16 additions & 20 deletions Project 27 - TabbarApp/TabbarApp/ThirdViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,37 @@ class ThirdViewController: UIViewController {
@IBOutlet weak var profileImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()

navigationController?.navigationBarHidden = true
self.profileImageView.alpha = 0
self.profileImageView.transform = CGAffineTransformMakeScale(0.5, 0.5)
navigationController?.isNavigationBarHidden = true
resetViewTransform()
}

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

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

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

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

self.profileImageView.transform = CGAffineTransformMakeScale(1, 1)
UIView.animate(withDuration: 0.5, delay: 0.1, usingSpringWithDamping: 0.7, initialSpringVelocity: 1, options: .curveEaseIn, animations: {
self.profileImageView.transform = CGAffineTransform(scaleX: 1, y: 1)
self.profileImageView.alpha = 1

}, completion: nil )
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
resetViewTransform()
}

// MARK:
func resetViewTransform() {
self.profileImageView.alpha = 0
self.profileImageView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
}
*/

}
25 changes: 0 additions & 25 deletions Project 27 - TabbarApp/TabbarApp/ViewController.swift

This file was deleted.

0 comments on commit 0bc7583

Please sign in to comment.