1

我正在尝试为 iPhone(iOS 6)获取一个自定义标签栏,我必须管理一个在栏上方升起的中央按钮(基于代码,https://github.com/tciuro/CustomTabBar)但现在我必须面对另一个功能:单击时按钮必须闪烁,并且必须删除光泽效果。关于获得它的最佳方法有什么建议吗?我对 iOS 及其动画的编程还是比较新的。

非常感谢

到目前为止我已经拥有的:

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在 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);


    }
}

但不确定它是否正确以及如何准确地做到这一点。

4

1 回答 1

2

在 iOS 上开始使用动画的最简单方法可能是使用该UIView animateWithDuration:(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

您在该块中更改的任何可动画值都将被动画化。

Core Animation 是广泛的,这仅仅触及了可以做的事情的表面,但它可能足以让你开始。

于 2013-08-21T15:33:39.470 回答