iphone中的自定义动画

时间:2013-04-18 09:15:26

标签: iphone ipad animation core-graphics

我正在创建具有如此多定制功能的Application。在某种意义上的定制,我希望为我的应用程序提供新的外观。在自定义部分,我想在我的应用程序中添加THIS种动画。

我在互联网上搜索了最后我找到了这么多的3D动画。但这些结果并不能满足我的需求。

建议我使用一些代码来使动画成为可能。

如果您提供任何源代码,那对我来说真的很有帮助。

1 个答案:

答案 0 :(得分:1)

这正是你想要的。像这样你的观点。 _transitionFrame是标签出口。标签放在显示器视图上。

包含QuartzCore框架并定义一个将度数转换为弧度的方法

#import <QuartzCore/QuartzCore.h>
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)

在视图中加载方法编写以下代码。

 - (void)viewDidLoad
{
    CGRect preFrame=_transitionFrame.frame;
    preFrame.origin.y+=preFrame.size.height/2;
    [_transitionFrame setFrame:preFrame];

    [UIView beginAnimations:nil context:nil];
    CATransform3D _3Dt = CATransform3DRotate(_transitionFrame.layer.transform,DEGREES_TO_RADIANS(90), 1.0, 0.0,0.0);
    [UIView setAnimationRepeatAutoreverses:YES];
    [UIView setAnimationRepeatCount:100];
    [UIView setAnimationDuration:1];

    [_transitionFrame.layer setAnchorPoint:CGPointMake(0.5, 1)];
    _transitionFrame.layer.transform=_3Dt;
    [UIView commitAnimations];

    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

enter image description here