相关疑难解决方法(0)

iOS自定义标签栏

我刚刚开始iOS开发,我只是在玩atm.

我正在尝试将默认的tabbar按钮转换为更自定义的内容.

经过一番环顾,我发现你可以为每个按钮创建自定义状态,所以我做了:

UIImage *selectedImage0 = [UIImage imageNamed:@"first.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"second.png"];

UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];

[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
Run Code Online (Sandbox Code Playgroud)

但是,我无法摆脱默认按钮,它会更改图像,但它不会更改我的整个按钮.

我还需要做些什么吗?

UIViewController *viewController1 = [[FirstViewController alloc]     initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

self.tabBarController = [[UITabBarController alloc] init];    
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];

UIImage *selectedImage0 = [UIImage imageNamed:@"first.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"second.png"];

UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];

[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
Run Code Online (Sandbox Code Playgroud)

uitabbarcontroller ios

4
推荐指数
1
解决办法
5万
查看次数

标签 统计

ios ×1

uitabbarcontroller ×1