效果展现swift
问题1 。这图怎么这么奇怪。app
由于图片是随便找的图ide
看网上说合适的图片设置:ui
1x :30X30spa
2x :60X60code
3x :90X90blog
也有讲48 x 32 是最合适的。。图片
没有ui妹子只能弄个demo图片。。;了博客
问题2 轮播图。不错。。。it
下片博客贴轮播图代码
正式开始
首先建立两个空的ViewController
HomeViewController
// // HomeViewController.swift // geekTime // // Created by liuan on 2020/9/14. // Copyright © 2020 liuan. All rights reserved. // import UIKit import Kingfisher class HomeViewController: BaseViewController{ override func viewDidLoad() { super.viewDidLoad() } }
MineViewController
// // MainViewController.swift // geekTime // // Created by liuan on 2020/9/14. // Copyright © 2020 liuan. All rights reserved. // import UIKit class MineViewController: BaseViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ }
而后修改 ViewController 代码
// // ViewController.swift // geekTime // // Created by liuan on 2020/9/14. // Copyright © 2020 liuan. All rights reserved. // import UIKit class ViewController: UITabBarController { override func viewDidLoad() { super.viewDidLoad() let homeVC = HomeViewController() homeVC.tabBarItem.image = UIImage(named: "home") homeVC.tabBarItem.selectedImage = UIImage(named: "home_select")?.withRenderingMode(.alwaysOriginal) homeVC.tabBarItem.title = "首页" homeVC.tabBarItem.setTitleTextAttributes([.foregroundColor:UIColor.hexColor(0x333333)], for: .selected) let navigationHomeVC = UINavigationController(rootViewController: homeVC) self.addChild(navigationHomeVC) let mineVC = MineViewController() mineVC.tabBarItem.image = UIImage(named: "My") mineVC.tabBarItem.selectedImage = UIImage(named: "My_select")?.withRenderingMode(.alwaysOriginal) mineVC.tabBarItem.title = "个人" mineVC.tabBarItem.setTitleTextAttributes([.foregroundColor:UIColor.hexColor(0x333333)], for: .selected) let navigationMineVC = UINavigationController(rootViewController: mineVC) self.addChild(navigationMineVC) } }
把 ViewController 设置为入口