Latest 1.3.0
Homepage https://github.com/uMina/XYXDomeTabBarController
License MIT
Platforms ios 9.0, requires ARC
Authors

使用Swift编写的轻量的DomeTabBar,凸起按钮可以任意设定一个位置。(已适配iPhoneX)

gif

可以使用cocospod管理到项目:

target 'MyApp' do
  use_frameworks!
  pod 'XYXDomeTabBarController'
end

框架一共三个文件,分别是:

  • XYXDomeTabBarController 继承自UITabBarController,在这里初始化所有ChildViewController
  • XYXDomeTabBar 用来自定义凸起按钮
  • XYXShadeView 用来自定义凸起按钮的点击后操作,也可以不使用此类.

简单又灵活的使用方式:

  1. 首先使用自定义的类,继承于XYXDomeTabBarController

    class YourViewController: XYXDomeTabBarController {}
  2. 在init方法中初始化tab. 这样子设定是生成了普通的TabBar
    convenience init() {
        self.init(nibName: nil, bundle: nil)
        let controllers = [UIViewController(),UIViewController(),UIViewController()]  //TabBar对应的几个Controller
        let titleItems = ["A","B","C"]              //TabbarItem名称
        let imageItems = ["item1","item2","item3"]  //TabbarItem图片
        for idx in 0...controllers.count-1 {
            addChildViewController(controllers[idx], title: titleItems[idx], imageName: imageItems[idx], selectedImageName: selectedItems[idx])
        }
    }
  3. 使用两个方法可以设定为带有突出按钮的TabBarController
    convenience init() {
      //***
      self.domeIndex = 2  //设定凸起按钮的位置,从0开始计数
      //self.domeBar.domeButtonSize = CGSize(width: 50, height: 50) //设定凸起按钮的大小
    }
  4. 可以通过对domeButtonClicked方法的重写, 来自定义当突出按钮被点击时的处理方式

    override func domeButtonClicked(_ sender: UIButton) {
        print("xxx 被点击了")
    }

    需注意的是:
    本Demo并不对domeIndex进行越界检查,调用时请根据自己添加的chilViewController的个数来确定domeIndex数值.
    以及,当domeIndex未设定,而设定了domeButtonSize, 则默认domeIndex=0.

domeIndex = 0时:👇

domeIndex = 0

domeIndex = 1时:👇

imdomeIndex = 1

domeIndex = 2时:👇

domeIndex = 2

domeIndex = 3时:👇

domeIndex = 3

domeIndex = 4时:👇

domeIndex = 4

需要注意的问题:

本项目不适合次级页面需要使用hidesBottomBarWhenPushed方法隐藏TabBar的项目使用。如果使用,会导致domeItem不会跟随隐藏。(测试SDK为iOS11.3)

Latest podspec

{
    "name": "XYXDomeTabBarController",
    "version": "1.3.0",
    "summary": "An easy way to create iOS tabBarController with/without dome button.",
    "description": "u5f00u53d1u8005u53efu4ee5u901au8fc7u7ee7u627fXYXDomeTabBarControlleru6765u5febu901fu751fu6210u5e26u51f8u8d77u6309u94aeu7684TabBarController, u4e5fu53efu76f4u63a5u751fu6210u666eu901au7684.nu53efu4ee5u8bbeu7f6eu51f8u8d77u6309u94aedomeButtonu7684imageu4ee5u53cahighlightedImage, u91cdu5199u5b83u7684u70b9u51fbu4e8bu4ef6domeButtonClicked(_ :).nu51f8u8d77u6309u94aeu7684u4f4du7f6eu53efu4ee5u901au8fc7domeIndexu81eau5b9au4e49,u51f8u8d77u6309u94aeu7684u5927u5c0fu4e5fu53efu4ee5u901au8fc7domeBar.domeButtonSizeu6765u81eau5b9au4e49.",
    "homepage": "https://github.com/uMina/XYXDomeTabBarController",
    "screenshots": "https://github.com/uMina/XYXDomeTabBarController/raw/master/ReadMe/aa.gif",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Teresa": "[email protected]"
    },
    "social_media_url": "https://umina.github.io/",
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/uMina/XYXDomeTabBarController.git",
        "tag": "1.3.0"
    },
    "source_files": "XYXDomeTabBarController/*.swift",
    "resources": "XYXDomeTabBarController/bundle/*.png",
    "requires_arc": true
}

Pin It on Pinterest

Share This