iPhone 4 在呈现视图时播放动画
我想将按钮放置在我的视图中围绕固定点的圆圈中。我可以这样做:
button.layer.anchorPoint = CGPointMake(offsetX/button.frame.size.width, offsetY/button.frame.size.height);
button.transform = [self calculateLabelPositionFromFixedPointWithOffsetClockwiseInDegrees:commonAngleRatio*startSpacing*spacingRatio++];
其中calculateLabelPositionFromFixedPointWithOffsetClockwiseInDegrees:angleInDegrees是我编写的一个函数,用于给我CGAfflineTransformMakeRotation。
我希望按钮在呈现视图时以动画方式“轨道”到正确的位置。我尝试放置一个计时器,将动画调用到“viewWillAppear”中,但它似乎不起作用。
编辑:我对 UIViewController 进行了两次子类化:
@interface HomeScreenAbstractParentController : UIViewController<UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate, ContextActionDelegate, RemoteControlDelegate> {...}
并且
@interface AnimatedController : HomeScreenAbstractParentController
{}
在 AnimatedController 中,不会调用以下方法。我将 AnimatedController 的视图添加到 homeScreenController 的背面(如天气应用程序中),当用户按下按钮时,视图会翻转到其背面。完成此操作后,背面应该为控件设置动画。
-(void)viewWillAppear:(BOOL)animated
{
NSLog(@"viewWillAppear");
[super viewWillAppear:animated];
}
-(void)viewDidAppear:(BOOL)animated
{
NSLog(@"viewDidAppear");
[super viewDidAppear:animated];
[self animateControls:nil];
}
在上述应用程序生命周期的哪个时刻,我应该安排计时器将按钮动画化到相应位置?是我翻转视图的时候吗?
I want to position buttons within my view in a circle around a fixed point. I can do this with :
button.layer.anchorPoint = CGPointMake(offsetX/button.frame.size.width, offsetY/button.frame.size.height);
button.transform = [self calculateLabelPositionFromFixedPointWithOffsetClockwiseInDegrees:commonAngleRatio*startSpacing*spacingRatio++];
Where the calculateLabelPositionFromFixedPointWithOffsetClockwiseInDegrees:angleInDegrees is a function that I wrote to give me CGAfflineTransformMakeRotation .
I would like the buttons to animate "orbiting" into the correct position when the view is presented. I tried putting a timer that will call animation into "viewWillAppear", but it doesn't seem to work.
Edit: I'm subclassing a UIViewController twice:
@interface HomeScreenAbstractParentController : UIViewController<UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate, ContextActionDelegate, RemoteControlDelegate> {...}
and
@interface AnimatedController : HomeScreenAbstractParentController
{}
Within the AnimatedController the following methods do not get called. I have the AnimatedController's view added to the back of the homeScreenController (as in Weather app), and when a user presses a button, the view flips to it's backside. The backside should animate controls when this is done.
-(void)viewWillAppear:(BOOL)animated
{
NSLog(@"viewWillAppear");
[super viewWillAppear:animated];
}
-(void)viewDidAppear:(BOOL)animated
{
NSLog(@"viewDidAppear");
[super viewDidAppear:animated];
[self animateControls:nil];
}
At which point in the lifecycle of the app above would I schedule the timer to animate buttons into positions? Is it when I flip the view over?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在你的 viewController 中:
in your viewController :