0

I have the following code

[UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{

            mainPage.frame=CGRectMake(0, -[UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height,[UIScreen mainScreen].bounds.size.width);

        } completion:nil];

Is there any way to control the animation duration of the subviews of mainPage.

Bassel Shawi
  • 604
  • 4
  • 11
  • 29

2 Answers2

3

You can use UIView:animateKeyframesWithDuration then use UIView:addKeyframeWithRelativeStartTime to set its start time and duration

[UIView animateKeyframesWithDuration:2 delay:0 options:0 animations:^{
    [UIView addKeyframeWithRelativeStartTime:0.32 relativeDuration:0.68 animations:^{
        view.frame = frame;
    }];
    [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:1 animations:^{
        subview.frame = frame2;
    }];
} completion:^(BOOL finished) {
}];
0

If you want the subviews to animate with a different duration then you'll need to animate each of them separately. You can loop through the mainPage.subviews array and issue an animateWithDuration:delay:options:animations:completion: call to each subview in turn, each with a different duration.

Duncan C
  • 128,072
  • 22
  • 173
  • 272