Как анимировать переход между двумя видами так, чтобы первое выглядело как восходящее, а второе - снизу? - PullRequest
0 голосов
/ 16 марта 2012

Я пробовал это, но это не работает:

[UIView animateWithDuration:2.0
                     animations:^{ 
                         [self.view addSubview:theSubView];
                         theSubView.frame=CGRectMake(self.view.frame.origin.x, 480, self.view.frame.size.width, self.view.frame.size.height);
                         self.view.transform=CGAffineTransformMakeTranslation(0, -480);
                         theSubView.transform=CGAffineTransformMakeTranslation(0, -480);
                     }];

1 Ответ

0 голосов
/ 16 марта 2012

попробуйте это: -

// Сначала создайте объект CATransition для описания перехода

    CATransition *transition = [CATransition animation];

// Animate over 3/4 of a second
transition.duration = 1;

// using the ease in/out timing function
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

// Now to set the type of transition. Since we need to choose at random, we'll setup a couple of arrays to help us.
NSString *types[4] = {kCATransitionMoveIn, kCATransitionPush, kCATransitionReveal, kCATransitionFade};
NSString *subtypes[4] = {kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom};



    transition.type =  types[1]; // choose ur type 



   transition.subtype = subtypes[2]; // choose ur type


// Finally, to avoid overlapping transitions we assign ourselves as the delegate for the animation and wait for the
// -animationDidStop:finished: message. When it comes in, we will flag that we are no longer transitioning.
transitioning = YES;
transition.delegate = self;

// Next add it to the containerView's layer. This will perform the transition based on how we change its contents.
[self.layer addAnimation:transition forKey:nil];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...