• 悬浮TabBar的实现--此段代码来自网络


    悬浮TabBar的实现

    这个TabBar看着像是用自定义TabBar做的,但事实上它还是用的系统的TabBar,给系统的tabBar.backgroundImage设置一张设计好的背景图片。


    TabBar.8

    添加后会发现顶部有一条阴影线,并且TabBar的高度也不够。阴影线与上图绿色线条之间变成了透明颜色,实现下面方法隐藏阴影线,并且调高TabBar的高度。


    TabBar.9
    //隐藏阴影线
        [[UITabBar appearance] setShadowImage:[UIImage new]];
    - (void)setupTabBarBackgroundImage {
        UIImage *image = [UIImage imageNamed:@"tab_bg"];
    
        CGFloat top = 40; // 顶端盖高度
        CGFloat bottom = 40 ; // 底端盖高度
        CGFloat left = 100; // 左端盖宽度
        CGFloat right = 100; // 右端盖宽度
        UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right);
        // 指定为拉伸模式,伸缩后重新赋值
        UIImage *TabBgImage = [image resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch];
        self.tabBar.backgroundImage = TabBgImage;
    
        [[UITabBar appearance] setShadowImage:[UIImage new]];
        [[UITabBar appearance] setBackgroundImage:[[UIImage alloc]init]];
    }
    
    //自定义TabBar高度
    - (void)viewWillLayoutSubviews {
    
        CGRect tabFrame = self.tabBar.frame;
        tabFrame.size.height = 60;
        tabFrame.origin.y = self.view.frame.size.height - 60;
        self.tabBar.frame = tabFrame;
    
    }



    文/JIAAIR(简书作者)
    原文链接:http://www.jianshu.com/p/5b1341e97757
    著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
  • 相关阅读:
    Codeforces Round 546 (Div. 2)
    Codeforces Round 545 (Div. 2)
    Codeforces Round 544(Div. 3)
    牛客小白月赛12
    Codeforces Round 261(Div. 2)
    Codeforces Round 260(Div. 2)
    Codeforces Round 259(Div. 2)
    Codeforces Round 258(Div. 2)
    Codeforces Round 257 (Div. 2)
    《A First Course in Probability》-chaper5-连续型随机变量-随机变量函数的分布
  • 原文地址:https://www.cnblogs.com/supersr/p/6100555.html
Copyright © 2020-2023  润新知