iOS navigation 透明处理

来源:互联网 发布:手机截取在线视频软件 编辑:程序博客网 时间:2024/06/05 10:23

#pragma mark - 导航条透明

- (void)setNavigationBarType {

    self.navigationController.navigationBar.translucent = YES;

    UIColor *color = [UIColorclearColor];

    CGRect rect =CGRectMake(0,0, GetScreenWidth(),64);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context =UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [colorCGColor]);

    CGContextFillRect(context, rect);

    UIImage *image =UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

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

    

    self.navigationController.navigationBar.clipsToBounds = YES;

}

0 0
原创粉丝点击