【问题标题】:Unexpected line on tab icon in tab bar选项卡栏中的选项卡图标上出现意外行
【发布时间】:2015-11-13 03:40:17
【问题描述】:

我想使用比正常尺寸更大的图片作为标签栏的图标,图片的高度高于标签栏。

如果我在标签栏的初始化中初始化哪个图标更大的标签,则图标上方有一条意外的线。代码如下:

FirstViewController *FVC = [[FirstViewController alloc] init];
UIImage *image2 = [UIImage imageNamed:@"test75x75.png"];

FVC.tabBarItem = [[UITabBarItem alloc] init];
[FVC.tabBarItem setImage:[image2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

SecondViewController *SVC = [[SecondViewController alloc] init];
SVC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:2];

NSArray *array = @[FVC, SVC];
self.myTabbarController.viewControllers = array;

UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:self.myTabbarController];
[self presentViewController:nvc animated:YES completion:^{}];

如截图,标签栏的那一行在FVC的图标上方(截图中的第一个标签)

但是如果我在标签栏初始化后添加一个具有更大图标的新标签, 图标上方没有线条,请参阅屏幕截图的第三个选项卡。 代码:

[self performSelector:@selector(updateTabbar) withObject:self afterDelay:2];

方法 'updateTabbar' 将第三个标签添加到标签栏中。

我的问题是: 如果我想在标签栏的初始化中创建标签(带有更大的图标图像),如何隐藏图标上方的意外行?

非常感谢。

【问题讨论】:

    标签: ios tabbar


    【解决方案1】:

    试试这个,

    self.tabBar.clipsToBounds = YES;
    

    用于删除 tabBar 顶部的行。

    【讨论】:

    • 谢谢。但这不是我想要的。这句话使图标变小以适合标签栏,但我想保持图像原始尺寸(图像尺寸高于标签栏的高度)。
    • @abentotoro: 把图片放上精确尺寸并调整。
    • 嗨,Vineesh TP,对不起,我没明白你的意思。第一个标签图像的大小与第三个图像的大小相同,但第三个图像上方没有意外的线。
    猜你喜欢
    • 1970-01-01
    • 2015-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多