zoukankan      html  css  js  c++  java
  • [翻译] NMBottomTabBarController

    NMBottomTabBarController

    A customisable tab bar controller for iOS written in Objective C. It uses auto layout.

    一个自定义的Tabbar控制器,使用了自动布局。

    Requirements

    1. iOS 7.1 +
    2. ARC
    Image Requirements for configuring the tab bar items
    1. Icon image  图标文件
    2. Selected and unselected background image  选中状态和未选中状态的背景图

    Features

    1. Uses autolayout 使用了自动布局
    2. You can set custom background images, icons and text( custom font and colour) for selected, unselected states of the tabs. 你可以使用自定义的背景图,图标,文本(包括字体颜色以及颜色)的选中和未选中状态值
    3. There are two configurations for the arrangement of text and icon image (Text to the right of icon image and text to the bottom of icon image)  有两种关于文本和图片的配置(图片在左文本在右或者图片在下文本在上)
    4. You can assign controllers for each of the tabs. 你可以给每一个tab设置一个控制器
    5. NMBottomTabBarController will take care of the switching and displaying of the controller views when user switches the tabs. NMBottomTabBarController会处理好控制器的切换操作
    6. In addition the tabs can be switched programatically as required. tabs会自动切换,所以不用你担心什么

    Installation

    1. Please Download the source files 先下载文件
    2. Drag and drop the NMBottomTabBarController folder into your project 将NMBottomTabBarController文件夹拖到你的项目当中
    3. Include objective-c #import "NMBottomTabBarController.h" wherever necessary 在需要的地方引入头文件NMBottomTabBarController.h

    Usage

    Add a controller and change its custom class to NMBottomTabBarController.

    添加一个控制器,然后让他继承自NMBottomTabBarController。

    From the controller where you want to display the tab bar controller you can do the initial set up.

    然后在你的控制器中进行初始化。

    To add a set of controllers that the tab bar controller manages
    UIViewController *oneController = [UIViewController new];
    oneController.view.backgroundColor = [UIColor greenColor];
    UIViewController *twoController = [UIViewController new];
    twoController.view.backgroundColor = [UIColor blueColor];
    UIViewController *threeController = [UIViewController new];
    threeController.view.backgroundColor = [UIColor purpleColor];
    UIViewController *fourController = [UIViewController new];
    fourController.view.backgroundColor = [UIColor orangeColor];
    
    NMBottomTabBarController *tabBarController = (NMBottomTabBarController *)self.window.rootViewController;
    
    tabBarController.controllers = [NSArray arrayWithObjects:oneController,twoController,threeController,fourController, nil];
    To set the separator image used between tabs
     tabBarController.tabBar.separatorImage = [UIImage imageNamed:@"separator.jpg"];
    Title and Text Orientation

    There are two title and text orientations

    有两种文本显示方式:

    1. kTitleToRightOfIcon - Places title to the right of the icon image 标题在右图标在左
    2. kTItleToBottomOfIcon - Places title to the nottom of the icon image You can learn how to set these in the next step 标题在下图标在上
    To set custom background images, icon, title text and title text orientation
     [tabBarController.tabBar configureTabAtIndex:0 andTitleOrientation :kTitleToRightOfIcon withUnselectedBackgroundImage:[UIImage imageNamed:@"unselected.jpeg"] selectedBackgroundImage:[UIImage imageNamed:@"selected.jpeg"] iconImage:[UIImage imageNamed:@"home"] andText:@"Home"andTextFont:[UIFont systemFontOfSize:12.0] andFontColour:[UIColor whiteColor]];
    To select a particular tab programatically
     [tabBarController selectTabAtIndex:0];
    Delegates

    There are two delegates available for NMBottomTabBarController

    NMBottomTabBarController提供两个代理方法:

    -(BOOL)shouldSelectTabAtIndex : (NSInteger)index;

    It can be used to determine whether to allow the selection of a particular tab

    这个可以用来决定是否允许某个tab被选中:

    -(void)didSelectTabAtIndex : (NSInteger)index;

    It can be used to perform any action once a tab is selected

    这个可以用来执行任何的操作,当某个tab被选中的时候

    To Do

    1. Set selected and unselected attributed text, icon images 设置选中与未选中状态的富文本
    2. Add a more button and display the controllers on next page when the tabs exceed a certain limit. 添加一个按钮,在另外的一个控制器中显示tab。

    License

    The project is licensed under the MIT license. For more information please see the [LICENSE][https://github.com/priankaliz/NMBottomTabBarController/blob/master/LICENSE] file

    Credits

    NMBottomTabBarController was developed for a project I work on. Please feel free to reach me atpriankaliz@gmail.com

  • 相关阅读:
    常见问题
    查询
    多对多关系
    prototype & __proto__
    new operator
    用户
    express.Router
    Express 应用生成器
    LeanCloud
    npm常用命令
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4375054.html
Copyright © 2011-2022 走看看