tabbar 透明度

2019-06-02  本文已影响0人  叶舞清风
#pragma mark ========= 修改tabbar 的高度
- (void)viewDidLayoutSubviews{
//      NSLog(@"%lf, %lf, %lf, %lf,", self.tabBar.frame.origin.x, self.tabBar.frame.origin.y, self.tabBar.frame.size.width, self.tabBar.frame.size.height);
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        CGRect frame = CGRectMake(0, self.tabBar.frame.origin.y-41, self.tabBar.frame.size.width, 90);
        self.tabBar.frame = frame;
    });
//    self.tabBar.backgroundColor = [UIColor clearColor];
    self.tabBar.backgroundImage = [self imageWithColor:[UIColor colorWithRed:1 green:1 blue:1 alpha:0]];
    
}
- (UIImage *)imageWithColor:(UIColor *)color
{
    CGRect rect = CGRectMake(0.0f,0.0f, 1.0f,1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context =UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

上一篇下一篇

猜你喜欢

热点阅读