小编wol*_*fan的帖子

在没有标题的UITabBarItem上设置辅助功能标签

我有一个像这样的UITabBarItem:

_Controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:nil image:nil tag:0];
Run Code Online (Sandbox Code Playgroud)

但是没有标题会删除可访问性和KIF测试所需的标签.我找到的另一种方法是设置标题并将其移出屏幕,但这似乎是一个hacky解决方案:

_Controller.tabBarItem.title = @"Foo";
_Controller.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, 200);
Run Code Online (Sandbox Code Playgroud)

是否可以使UITabBarItem没有标题,但仍然有可访问性标签?

编辑以添加标签栏和背景按钮代码的完整代码:

- (void) loadViewController {
    _Controller = [[UIViewController alloc] init];
    UIImage *normalImage = [UIImage imageNamed:@"bar.png"];
    UIImage *selectedTabImage = [UIImage imageNamed:@"barHover.png"];
    [self addCenterButtonWithImage:normalImage
                    highlightImage:selectedTabImage];

    _Controller.tabBarItem = [[UITabBarItem alloc] initWithTitle:nil image:nil tag:0];
}

// Create a custom UIButton and add it to the center of our tab bar
-(void) addCenterButtonWithImage:(UIImage*)buttonImage highlightImage:(UIImage*)highlightImage
{
    UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
    [button setBackgroundImage:buttonImage …
Run Code Online (Sandbox Code Playgroud)

iphone ios kif ios7

7
推荐指数
2
解决办法
8046
查看次数

标签 统计

ios ×1

ios7 ×1

iphone ×1

kif ×1