iOS UINavigationController导航条背景透明



//方法一


- (void)setCleanNavtion {


    //自定义背景

    [self.navigationController.navigationBarsetBackgroundImage:[UIImagenew] forBarMetrics:UIBarMetricsDefault];

    //消除阴影

   self.navigationController.navigationBar.shadowImage = [UIImage new];

}


//方法二

- (void)setNavtion {

    self.navigationController.navigationBar.translucent=YES;

    UIColor *color=[UIColorclearColor];

    CGRect rect =CGRectMake(0,0,self.view.frame.size.width,64);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context =UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [colorCGColor]);

    CGContextFillRect(context, rect);

    UIImage *image =UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    [self.navigationController.navigationBarsetBackgroundImage:imageforBarMetrics:(UIBarMetricsDefault)];

    self.navigationController.navigationBar.clipsToBounds=YES;

}






 

你可能感兴趣的:(导航控制器)