iOS标签栏中的自定义和动画按钮

问题描述:

我想要为iPhone(iOS 6)获得自定义标签栏,并且必须管理通过酒吧(基于代码https://github.com/tciuro/CustomTabBar)提出的*按钮,但现在我不得不面对另一个功能:点击时按钮必须闪烁,并且必须移除光泽效果。任何有关最佳方式的建议?我仍然使用iOS及其动画进行相对较新的编程。iOS标签栏中的自定义和动画按钮

非常感谢您

我已经到目前为止有:

enter image description here

enter image description here

enter image description here

在MBCenteredButtonVC(在故事板的主入口)

#import <UIKit/UIKit.h> 

@interface MBCenteredButtonViewController : UITabBarController <UITabBarDelegate> 

@property(nonatomic, weak) IBOutlet UIButton *centerButton; 


@end 

及其实施:

每个项目
- (void)viewDidLoad 
    { 
     [super viewDidLoad]; 

     [self.tabBar setSelectedImageTintColor:[UIColor colorWithRed:171/225.0 green:233/255.0 blue:8/255.0 alpha:1]]; 
     [self.tabBar setBackgroundImage:[UIImage imageNamed:@"bar-back.png"]]; 

    // Do any additional setup after loading the view. 
     [self addCenterButtonWithImage:[UIImage imageNamed:@"button-rocketBg.png"] highlightImage:[UIImage imageNamed:@"button-rocketBg-active.png"] target:self action:@selector(buttonPressed:)]; 
    } 

图片使用的XCode视图的属性中定义。所以,通过这种方式,我得到了一个*按钮,其余部分已经改变了,并且我已经改变了选定项目的颜色,但我需要在内容加载时闪烁(它可能需要一些时间)。

我觉得我要实现这个功能按下按钮时:

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item 
{ 
    NSLog(@"Selected tab bar item: %i", item.tag); 


    } 
} 

,但不知道它的正确方法,以及如何做到这一点没错。

在iOS上开始动画的最简单方法可能是使用UIViewanimateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations方法。

文档浏览:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW111

是动画,你该块的变化将是动画的任何值。

核心动画是广泛的,这只是勉强可以做的表面,但它可能足以让你开始。

+0

我已经设法获得独立的按钮动画做这样的事情:myButton.imageView.animationImages = [NSArray的arrayWithObjects:[UIImage的imageNamed:@ “[email protected]”], [UIImage的imageNamed :@“[email protected]”], 无]; myButton.imageView.animationDuration = 0.7; //任何你想要的(以秒为单位) [myButton.imageView startAnimating];但我的问题是如何在内容加载时使用故事板和iOS 6在标签栏视图中为每个项目获取它 – bitsdisasters