效果展示
问题1 。这图怎么这么奇怪。
因为图片是随便找的图
看网上说合适的图片设置:
1x :30X30
2x :60X60
3x :90X90
也有讲48 x 32 是最合适的。。
没有ui妹子只能弄个demo图片。。;了
问题2 轮播图。不错。。。
下片博客贴轮播图代码
正式开始
首先创建两个空的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 设置为入口