iOS自定义导航栏

//    IOS自定义导航栏

    UILabel *navTitleText = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];

    navTitleText.backgroundColor = [UIColor clearColor];

    navTitleText.textColor=[UIColor blackColor];

    navTitleText.textAlignment = NSTextAlignmentCenter;

    [navTitleText setFont:[UIFont systemFontOfSize:25.0]];

    [navTitleText setText:@"XXX"];

    self.navigationItem.titleView=navTitleText;

    

//    IOS中右边按钮

    UIBarButtonItem * rightButton = [[UIBarButtonItem alloc]

                                     initWithTitle:@"next"

                                     style:UIBarButtonItemStyleBordered

                                     target:self

                                     action:@selector(callModalList)];

    

    rightButton.image=[UIImage imageNamed:@"right_btn.png"];

    rightButton.tintColor=[UIColor colorWithRed:74/255.0 green:74/255.0 blue:74/255.0 alpha:1.0];

    

    self.navigationItem.rightBarButtonItem = rightButton;

    

//    导航字体设置

            [[UINavigationBar appearance] setTitleTextAttributes:

             [NSDictionary dictionaryWithObjectsAndKeys:

              [UIColor whiteColor],

              NSForegroundColorAttributeName,nil]];

    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

            [[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];

    

            [self..navigationBar setBarTintColor:[UIColor whiteColor]];

    

            if(isiOS7orLater) {

                // 状态栏白色

                [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

            [[UINavigationBar appearance] setTranslucent:NO];

            [UIApplication setStatusBarHidden:YES];

                // 设置导航条颜色

            [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"homepage_navi_bar_bg.png"] forBarMetrics:UIBarMetricsDefault];

            //        }

            [[UINavigationBar appearance] setBackgroundColor:[UIColor blackColor]];

    



转载请注明出处:http://blog.csdn.net/sevenquan




你可能感兴趣的:(ios,ios,NavigationBar,iOS自定义导航栏)