OGeek|极客世界-中国程序员成长平台

标题: ios - UITab 栏 - 选择指示器图像 - 更改位置 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:12
标题: ios - UITab 栏 - 选择指示器图像 - 更改位置

我正在使用 UITabBarController。在我的 AppDelgate 中,我将 selectionIndicatorImage 设置为简单的白线。这显示在标签栏项目的中间。我希望它显示在我的标签栏项目的顶部,突出显示它已被选中。我尝试制作一个顶部有白线,底部透明的图像,但它只是显示在我的标签栏上方。制作这张图片是否需要一定的尺寸才能达到我想要的效果?

enter image description here

我正在使用的图片:https://www.dropbox.com/s/zva77z9yt6rcfsg/SelectedTab.png?dl=0

 UIImage *selectedImage = [[UIImage imageNamed"SelectedTab"] stretchableImageWithLeftCapWidth:0 topCapHeight:0];

[[UITabBar appearance] setSelectionIndicatorImage:selectedImage]



Best Answer-推荐答案


您必须创建带有顶部白线的 translucent selectedTab(请参阅 zip 文件),并且 height 应该是 48 Pixel

查看此链接 https://www.dropbox.com/s/j38mqj8sd0qgv8f/selectedTab.zip?dl=0

  [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed"selectedTab.png"]];
    [[UITabBar appearance] setBarTintColor:[UIColor blackColor]];

结果: enter image description here

关于ios - UITab 栏 - 选择指示器图像 - 更改位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50631644/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4