Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an application in which I need to

add a subview to a view with presentmodalview type animation

But in

CATransition

I didn't find any type of transition like that. Also in

UItransitionstyle

Can anybody guide me on this?

share|improve this question

4 Answers

I see there are many answer's already posted. This one, if you only want to use CATransition

CATransition *animation = [CATransition animation];
[animation setType:kCATransitionMoveIn];
[animation setSubtype:kCATransitionFromTop];
[animation setDuration:0.6f];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                              kCAMediaTimingFunctionEaseInEaseOut]];
[subview.layer addAnimation:animation forKey:@"someTransition"];
share|improve this answer

Change the frame of the subview insite the UIView Animation, like as follows,

initially set the

subView.frame=CGRectMake(0,self.view.frame.size.height,your_width,your_height);

then set the required frame position inside the animation

[UIView animateWithDuration:0.25 delay:0 options: UIViewAnimationCurveEaseOut animations:^ {

        // set subView's frame

    } completion:^(BOOL finished) {

    }
     ];
share|improve this answer

Try to use UIView animation block:

yourView.frame = CGRectMake(0, yourSuperView.frame.size.height, yourView.frame.size.width, yourView.frame.size.height);
[yourSuperView addSubview:yourView];
[UIView animateWithDuration:1.0 animations:^{
    yourView.frame = CGRectMake(0, 0, yourView.frame.size.width, yourView.frame.size.height);
} completion:^(BOOL finished) {
    //Task to do on Animation completion.
}];

You change the animation duration according to your convince. Also you can use following:

[UIView animateWithDuration:1.0 animations: {
      //your Implemntation
}];

or

[UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationCurveEaseIn animations:^{

} completion:^(BOOL finished) {

}];

Please check the UIView class reference for animation option in UIViewAnimationOptions section and detail of methods.

Hope this helps

share|improve this answer

Try this code

[self.view bringSubviewToFront:yoursubview];
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionFade];
[animation setDuration:1.00];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                              kCAMediaTimingFunctionEaseIn]];
[yoursubview.layer addAnimation:animation forKey:@"fadeTransition"];

For more info check these links

  1. Link1
  2. Link2
  3. Link 3

i Hope it works for you.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.