如何在Xcode中设置切换按钮的动画?

时间:2011-06-17 09:42:14

标签: iphone objective-c xcode

导航栏上有一个名为Map and List

的按钮

按下地图时我会

- (IBAction)Map:(id)sender {
    self.tabBarController.navigationItem.rightBarButtonItem =self.List;
    [BNUtilitiesQuick AnimateSwitchingWithParent:SwitchViews From:theTable To:GoogleMapController.view];

}

- (IBAction)List:(id)sender {
    self.tabBarController.navigationItem.rightBarButtonItem =self.Map;
    [BNUtilitiesQuick AnimateSwitchingWithParent:SwitchViews From:GoogleMapController.view To:theTable];

}

现在,奇怪的是,我不想设置self.tabBarController.navigationItem.rightBarButtonItem =self.Map;并使按钮快速分割,我想我想为该切换设置动画。

我该怎么做?

另外,我如何动画推送和弹出视图到导航控制器?如何为切换 tabBar 项目的用户设置动画?

1 个答案:

答案 0 :(得分:1)

如果您查看UITabBar文档:UITabBar

- (void)setItems:(NSArray *)items animated:(BOOL)animated

尝试制作所需的新标签栏项目数组,并将其设置为UITabBar

// Assuming "tabBar" is a UITabBar, probably part of a UITabBarController
// Assuming "newItem" is a new UITabBarItem containing the new buttons you want
// animate in.

NSArray* newItemArray = [NSArray arrayWithObjects:newItem,nil];
[tabBar setItems:newItemArray animated:YES];

// This should work, and you can include more than just one new item for multiple
// buttons on the tab bar.

希望对你有用!