美文网首页
iOS13中 UITabBar隐藏线条、定位不起作用问题

iOS13中 UITabBar隐藏线条、定位不起作用问题

作者: 三岁就很乖 | 来源:发表于2020-05-06 21:36 被阅读0次

iOS13中 UITabBar隐藏线条、定位不起作用问题
https://blog.csdn.net/tianyitianyi1/article/details/101942168

1. 隐藏线条处理   

    CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
    CGContextFillRect(context, rect);
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    if (@available(iOS 13.0, *)) {
        UITabBarAppearance *tabBarAppearance = [self.tabBar.standardAppearance copy];
        [tabBarAppearance setBackgroundImage:img];
        [tabBarAppearance setShadowColor:[UIColor clearColor]];
        [self.tabBar setStandardAppearance:tabBarAppearance];
    } else {
        [self.tabBar setBackgroundImage:img];
        [self.tabBar setShadowImage:img];
    }

 

2. 更改UITababr的位置

    之前是放在viewWillLayoutSubviews 里面的,但从iOS13开始,放到这个方法里面修改位置不再起作用。需要放到viewDidLayoutSubviews里面

    - (void)viewDidLayoutSubviews{
        [super viewDidLayoutSubviews];

        CGRect tabFrame = self.tabBar.frame;
        tabFrame.size.height = 44;
        tabFrame.origin.y = 27;
        self.tabBar.frame = tabFrame;
    }

相关文章

网友评论

      本文标题:iOS13中 UITabBar隐藏线条、定位不起作用问题

      本文链接:https://www.haomeiwen.com/subject/zdigghtx.html