iOS 设置UINavtionController navigationBar 为透明颜色

 //设置背景颜色

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

        NSArray *list=self.navigationController.navigationBar.subviews;

        for (id obj in list) {

            if ([obj isKindOfClass:[UIImageView class]]) {

                UIImageView *imageView=(UIImageView *)obj;

                imageView.hidden=YES;

            }

        }

        UIImageView *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, -20, 420, 64)];

        imageView.image=[UIImage imageNamed:@"clear"];

        [self.navigationController.navigationBar addSubview:imageView];

        [self.navigationController.navigationBar sendSubviewToBack:imageView];

        self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];

        

    }

你可能感兴趣的:(iOS,点~滴)