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]];//導航欄左右兩邊按鈕顏色


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章