所以我有一個標籤欄應用程序,我已經把像頂高音揚聲器的效果,當你從標籤欄按下一個按鈕,一個箭頭滑動到所選擇的按鈕,這是一個的確涼「動畫」 但問題是這樣的箭頭總是在我的第一個計劃,當(例如)我想在全屏播放視頻箭頭已經在那裏,當我切換到另一種觀點沒有任何標籤酒吧,箭頭仍然存在...問題的一個形象,總是在第一個計劃
我的代碼在AppDelegate中。 在.hi有:
AppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIImageView *tabBarArrow;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@property (nonatomic, retain) UIImageView *tabBarArrow;
- (CGFloat) horizontalLocationFor:(NSUInteger)tabIndex;
- (void) addTabBarArrow;
,並在我的.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
_tabBarController.delegate = self;
// Add the tab bar controller's current view as a subview of the window
self.window.rootViewController = self.tabBarController;
[self addTabBarArrow];
[self.window makeKeyAndVisible];
return YES;
}
-(void) addTabBarArrow {
UIImage* tabBarArrowImage = [UIImage imageNamed:@"Arrow.png"];
self.tabBarArrow = [[[UIImageView alloc] initWithImage:tabBarArrowImage] autorelease];
CGFloat verticalLocation = self.window.frame.size.height - _tabBarController.tabBar.frame.size.height
- tabBarArrowImage.size.height + 6;
tabBarArrow.frame = CGRectMake([self horizontalLocationFor:0], verticalLocation,
tabBarArrowImage.size.width, tabBarArrowImage.size.height);
[self.window addSubview:tabBarArrow];
}
-(void)tabBarController:(UITabBarController *)theTabBarController didSelectViewController:(UIViewController *)viewController{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
CGRect frame = tabBarArrow.frame;
frame.origin.x = [self horizontalLocationFor:_tabBarController.selectedIndex];
tabBarArrow.frame = frame;
[UIView commitAnimations];
}
-(CGFloat) horizontalLocationFor:(NSUInteger)tabIndex{
CGFloat tabItemWidth = _tabBarController.tabBar.frame.size.width/_tabBarController.tabBar.items.count;
CGFloat halfTabItemWidth = (tabItemWidth/2.0) - (tabBarArrow.frame.size.width/2.0);
return (tabIndex * tabItemWidth) + halfTabItemWidth;
}
我認爲是所有 感謝幫助我,因爲我真的不知道該怎麼做..
是的,我會看到,但與全屏視頻的問題是,我使用YouTube的移動版本,所以我沒有任何代碼對於.. – AlexF
但是,是的,它真的不是我要找的.. – AlexF