iOS-设置导航栏透明及字体、左右按钮、边框颜色

- (void) setNavBarImg:(UINavigationBar *)navBar

{

#define kSCNavBarImageTag 10

    

    if ([navBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])

    {

        //if iOS 5.0 and later

        [navBar setBackgroundImage:[UIImage imageNamed:(@"main_navigation_bg")] forBarMetrics:UIBarMetricsDefault];

    }

    else

    {

        UIImageView *imageView = (UIImageView *)[navBar  viewWithTag:kSCNavBarImageTag];

        [imageView setBackgroundColor:[UIColor clearColor]];

        if (imageView == nil)

        {

            imageView = [[UIImageView alloc] initWithImage:

                         [UIImage imageNamed:(@"main_navigation_bg")]];

            [imageView setTag:kSCNavBarImageTag];

            [navBar insertSubview:imageView atIndex:0];

        }

    }

}





    [self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor clearColor]]];//导航栏最下边线颜色

    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];//导航栏字体颜色

    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];//导航栏左右两边按钮颜色


你可能感兴趣的:(iOS,随手记)