码迷,mamicode.com
首页 > 其他好文 > 详细

UINavigationControll & UITabbarViewController

时间:2016-03-31 14:44:22      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:

1.设置全局导航backButton标题为nil or 自定义标题

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];

 

UIBarButtonItem *returnButtonItem = [[UIBarButtonItem alloc] init];

    returnButtonItem.title = @"返回";

    self.navigationItem.backBarButtonItem=returnButtonItem;

 

2.设置导航返回按钮隐藏

 [self.navigationItem setHidesBackButton:YES];

3.设置导航栏原点坐标

self.navigationController.navigationBar.translucent = NO;

4.设置文字颜色

self.tabBar.tintColor = [UIColor yellowColor];

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor greenColor],NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];

5.设置图片不被渲染

[[UIImage imageNamed:@""] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

6.使用系统自带UITabbarController方法:

- (void)setupChildViewController:(UIViewController *)childVC

                           title:(NSString *)title

                       imageName:(NSString *)imageName

               selectedImageName:(NSString *)selectedImageName

                          tabBar:(UITabBar *)tabBar

                           index:(NSUInteger)index {

    childVC.title = title;

    UITabBarItem *item = [tabBar.items objectAtIndex:index];

    UIImage *image = [UIImage imageNamed:imageName];

    UIImage *selectedImage = [UIImage imageNamed:selectedImageName];

    // 设置不对图片进行蓝色的渲染

    [item setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

    [item setSelectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

}

7.使用导航代理方法隐藏二三级视图的UITabbar<UINavigationControllerDelegate>

-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

{

    NSInteger subviewCount=navigationController.viewControllers.count;

    if (subviewCount > 1) {

         self.tabBar.hidden = YES;//自定义的视图,使用_customTabbarView.hidden = YES;

    }

    if (subviewCount == 1) {

         self.tabBar.hidden = NO;//_customTabbarView.hidden = NO;

    }

}

 

UINavigationControll & UITabbarViewController

标签:

原文地址:http://www.cnblogs.com/zbuser/p/5340995.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!