Skip to content

Commit

Permalink
1.更新样式支持
Browse files Browse the repository at this point in the history
  • Loading branch information
Caffe-del committed Sep 17, 2020
1 parent d8e9a06 commit 131dd5e
Show file tree
Hide file tree
Showing 43 changed files with 169 additions and 110 deletions.
6 changes: 6 additions & 0 deletions BottomBar/Assets.xcassets/Normal/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"images" : [
{
"filename" : "bbs_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "bbs_selected@2x.png",
"filename" : "tabVC_mine@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"images" : [
{
"filename" : "account_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"images" : [
{
"filename" : "account_unselect.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"images" : [
{
"filename" : "bbs_unselect.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "bbs_unselect@2x.png",
"filename" : "tabVC_putoo_h@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 0 additions & 22 deletions BottomBar/Assets.xcassets/music_selected.imageset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
22 changes: 0 additions & 22 deletions BottomBar/Assets.xcassets/music_unselect.imageset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
22 changes: 0 additions & 22 deletions BottomBar/Assets.xcassets/video_selected.imageset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
22 changes: 0 additions & 22 deletions BottomBar/Assets.xcassets/video_unselect.imageset/Contents.json

This file was deleted.

Binary file not shown.
Diff not rendered.
15 changes: 15 additions & 0 deletions BottomBar/MusicViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MusicViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .white
self.navigationController?.delegate = self
// Do any additional setup after loading the view.
}

Expand All @@ -27,3 +28,17 @@ class MusicViewController: UIViewController {
}
}
}

extension MusicViewController: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return nil
}

func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
return nil
}

func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {

}
}
37 changes: 30 additions & 7 deletions BottomBar/RootTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,35 @@ enum BottomBarStyle {
class RootTabBarController: UITabBarController {

private var bottomBarStyle = BottomBarStyle.miniPlayViewOnly
// private let iconList = ["music_unselect", "video_unselect", "bbs_unselect", "account_unselect"]
private let iconList = ["skin_tab_home_normal", "skin_tab_video_normal", "skin_tab_putoo_normal", "skin_tab_mine_normal"]
private let titleList = ["音乐", "视频", "扑通", "我的"]
private var itemList = [RootTabBarItem]()
private let itemsInfo: [(normal:String?, select:String?, title:String?)] =
[("tabVC_music","tabVC_music_h","音乐"),
("tabVC_video","tabVC_video_h","视频"),
("tabVC_putoo","tabVC_putoo_h","扑通"),
("tabVC_mine","tabVC_mine_h","我的"),]

// private let itemsInfo: [(normal:String?, select:String?, title:String?)] =
// [("tabVC_music","tabVC_music_h",nil),
// ("tabVC_video","tabVC_video_h",nil),
// ("tabVC_putoo","tabVC_putoo_h",nil),
// ("tabVC_mine","tabVC_mine_h",nil),]

override func viewDidLoad() {
super.viewDidLoad()

let tabBar = RootTabBar()
tabBar.RTDelegate = self

var itemList = [RootTabBarItem]()
for (index, item) in iconList.enumerated() {
for (index, info) in itemsInfo.enumerated() {
let tabBatItem = RootTabBarItem()
tabBatItem.icon = item
tabBatItem.title = titleList[index]
if let iconNormal = info.normal, let iconSelect = info.select {
tabBatItem.iconNormal = iconNormal
tabBatItem.iconSelected = iconSelect
}

if let title = info.title {
tabBatItem.title = title
}
tabBatItem.tag = index
itemList.append(tabBatItem)
}
Expand Down Expand Up @@ -71,6 +85,7 @@ class RootTabBarController: UITabBarController {
}

self.tabBar.frame = CGRect.init(x: 0, y: tabBarY, width: screenWidth, height: layout.tabBarHeight + layout.miniPlayViewHeight + safeAreaBottomHeight)
self.updateBarItems(selected: self.selectedIndex)
}

func updateBottomStyle(_ style: BottomBarStyle) {
Expand All @@ -81,12 +96,20 @@ class RootTabBarController: UITabBarController {
self.view.layoutIfNeeded()
}, completion: nil)
}

func updateBarItems(selected:Int) {
for (idx,item) in itemList.enumerated() {
let state:itemState = selected==idx ? .selected : .normal
item.reloadData(state: state)
}
}

}

extension RootTabBarController: MainTabBarDelegate {
func tabBar(_ tabBar: RootTabBar, didSelectedIndex: Int) {
self.selectedIndex = didSelectedIndex;
self.updateBarItems(selected: didSelectedIndex)
}

}
Loading

0 comments on commit 131dd5e

Please sign in to comment.