• UINavigationController


    -(void)resetTabbarController:(UITabBarController *)controller {

        NSArray *arr = controller.tabBar.items;

        

        UITabBarItem *item0 = [arr objectAtIndex:0];

      //使用指定图片

        [item0 setSelectedImage:[[UIImage imageNamed:@"icon_everyday_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        [item0 setImage:[[UIImage imageNamed:@"icon_everyday"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        

        UITabBarItem *item1 = [arr objectAtIndex:1];

        [item1 setSelectedImage:[[UIImage imageNamed:@"icon_order_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        [item1 setImage:[[UIImage imageNamed:@"icon_order_normal"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        

        UITabBarItem *item2 = [arr objectAtIndex:2];

        [item2 setSelectedImage:[[UIImage imageNamed:@"icon_broker_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        [item2 setImage:[[UIImage imageNamed:@"icon_broker_normal"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        

        

        UITabBarItem *item3 = [arr objectAtIndex:3];

        [item3 setSelectedImage:[[UIImage imageNamed:@"icon_shop_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        [item3 setImage:[[UIImage imageNamed:@"icon_shop_normal"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        

        UITabBarItem *item4 = [arr objectAtIndex:4];

        [item4 setSelectedImage:[[UIImage imageNamed:@"icon_houses_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        [item4 setImage:[[UIImage imageNamed:@"icon_houses_normal"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

        

        CGRect frame = CGRectMake(0, 0, SCREEN_WIDTH, 49);

      //修改tabbar颜色

        UIView *v = [[UIView alloc] initWithFrame:frame];

        UIImage *img = [Utility imageWithColor:[UIColor whiteColor]];

        UIColor *color = [[UIColor alloc] initWithPatternImage:img];

        v.backgroundColor = color;

        [controller.tabBar insertSubview:v atIndex:0];

        controller.tabBar.tintColor = ColorBg3;

        //修改tabbaritem文字颜色

        [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithWhite:0.0 alpha:0.87]} forState:UIControlStateNormal];

        controller.tabBar.barTintColor = [UIColor colorWithWhite:0.0 alpha:0.87];

        controller.tabBar.opaque = NO;

        

    //    [controller setSelectedIndex:0];

    }

    1、UINavigationBar 背景色修改

    - (void)viewWillAppear:(BOOL)animated

    {

        UINavigationBar *bar = self.navigationController.navigationBar;

        //关键是这几句。。。。。

        [bar setTranslucent:NO];

        

        if (CURRENT_IOS_VERSION >= 7) {

            if ([self.navigationController.navigationBar respondsToSelector:@selector( setBackgroundImage:forBarMetrics:)]){

                [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg_title_up"] forBarMetrics:UIBarMetricsDefault];

            }

        }else{

            [bar setBackgroundImage:[Utility imageWithColor:[Utility stringToColor:@"#df4919"]] forBarMetrics:UIBarMetricsDefault];

            [bar.layer setMasksToBounds:YES];

            [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;

        }

        if ([UINavigationBar instancesRespondToSelector:@selector(setShadowImage:)])

        {

            [[UINavigationBar appearance] setShadowImage:[UIImage imageWithColor:[UIColor clearColor] size:CGSizeMake(320, 3)]];

        }    

        [super viewWillAppear:animated];

        //[MobClick beginLogPageView:NSStringFromClass([self class])];

    }

    2、设置返回按钮

    -(void) setShowBackBtn:(BOOL)_showBackBtn

    {

        showBackBtn = _showBackBtn;

        

        if (self.navigationController.navigationBarHidden)

        {

            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];

            [btn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];

            UIImage *normalImg = [UIImage imageNamed:@"icon_back_nomal"];

            UIImage *hightLightImg = [UIImage imageNamed:@"icon_back_press"];

            [btn setImage:normalImg forState:UIControlStateNormal];

            [btn setImage:hightLightImg forState:UIControlStateHighlighted];

            [btn  setFrame:CGRectMake(0, 22, 26, 39)];

            [btn setImageEdgeInsets:UIEdgeInsetsMake(10, 5, 10, 10)];

            [self.view addSubview:btn];

        } else {

            if (showBackBtn) {

                UIBarButtonItem *backItem = [UIFactory backItemWithTarget:self selector:@selector(backAction:)];

                if (CURRENT_IOS_VERSION < 7.0) {

                    UIBarButtonItem *flexSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace

                                                                                               target:self

                                                                                               action:nil];

                    flexSpacer.width = 10;

                    

                    [self.navigationItem setLeftBarButtonItems:[NSArray arrayWithObjects:flexSpacer,backItem, nil]];

                    [flexSpacer release];

                    

                }else{

                    [self.navigationItem setLeftBarButtonItem:backItem];

                }

                

            }else{

                self.navigationItem.leftBarButtonItem = nil;

            }

        }

    }

  • 相关阅读:
    引用 struts2标签详解
    Java 中日期的计算
    在一个FORM中实现多个ACTION动作
    java.lang.OutOfMemoryError: PermGen space最好的解决方法
    Java实现和栈的应用举例
    Java的自动装箱和拆箱
    oracle11g更改字符集AL32UTF8为ZHS16GBK
    设计的臭味
    OOD设计五个原则
    推荐JQuery学习简介
  • 原文地址:https://www.cnblogs.com/ldc529/p/4528795.html
Copyright © 2020-2023  润新知