diff --git a/BubbleTabBar.podspec b/BubbleTabBar.podspec index 281e6d5..5b242f1 100644 --- a/BubbleTabBar.podspec +++ b/BubbleTabBar.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'BubbleTabBar' s.swift_version = '4.2' - s.version = '0.8.2' + s.version = '0.8.3' s.summary = 'One another nice animated tabbar' s.homepage = 'https://github.com/Cuberto/bubble-icon-tabbar' # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' diff --git a/BubbleTabBar/Classes/BubbleTabBar.swift b/BubbleTabBar/Classes/BubbleTabBar.swift index 0e8fdb6..70c881c 100644 --- a/BubbleTabBar/Classes/BubbleTabBar.swift +++ b/BubbleTabBar/Classes/BubbleTabBar.swift @@ -9,7 +9,7 @@ import UIKit open class BubbleTabBar: UITabBar { - + private var buttons: [CBTabBarButton] = [] public var animationDuration: Double = 0.3 @@ -26,7 +26,7 @@ open class BubbleTabBar: UITabBar { select(itemAt: index, animated: false) } } - + open override var tintColor: UIColor! { didSet { buttons.forEach { button in @@ -36,12 +36,12 @@ open class BubbleTabBar: UITabBar { } } } - + public override init(frame: CGRect) { super.init(frame: frame) configure() } - + public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) configure() @@ -81,24 +81,24 @@ open class BubbleTabBar: UITabBar { csContainerBottom.constant = -safeAreaInsets.bottom } else { } } - + open override var items: [UITabBarItem]? { didSet { reloadViews() } } - + open override func setItems(_ items: [UITabBarItem]?, animated: Bool) { super.setItems(items, animated: animated) reloadViews() } - private var spacers: [UIView] = [] + private var spaceLayoutGuides:[UILayoutGuide] = [] private func reloadViews() { subviews.filter { String(describing: type(of: $0)) == "UITabBarButton" }.forEach { $0.removeFromSuperview() } - buttons.forEach { $0.removeFromSuperview()} - spacers.forEach { $0.removeFromSuperview()} + buttons.forEach { $0.removeFromSuperview() } + spaceLayoutGuides.forEach { self.container.removeLayoutGuide($0) } buttons = items?.map { self.button(forItem: $0) } ?? [] buttons.forEach { (button) in self.container.addSubview(button) @@ -108,22 +108,18 @@ open class BubbleTabBar: UITabBar { buttons.first?.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 10.0).isActive = true buttons.last?.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -10.0).isActive = true let viewCount = buttons.count - 1 - spacers = [] + spaceLayoutGuides = []; for i in 0..CFBundlePackageType FMWK CFBundleShortVersionString - 0.8.2 + 0.8.3 CFBundleVersion $(CURRENT_PROJECT_VERSION) diff --git a/Example/ViewController.swift b/Example/ViewController.swift index 905fe28..a3070c8 100644 --- a/Example/ViewController.swift +++ b/Example/ViewController.swift @@ -32,6 +32,10 @@ class ViewController: UIViewController { tabBarController.viewControllers = [eventsVC, searchVC, activityVC, settingsVC] tabBarController.tabBar.tintColor = #colorLiteral(red: 0.1579992771, green: 0.1818160117, blue: 0.5072338581, alpha: 1) self.navigationController?.pushViewController(tabBarController, animated: true) + + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + tabBarController.selectedIndex = 2 + } } override var preferredStatusBarStyle: UIStatusBarStyle {