dniprodev
dniprodev

Reputation: 21

add subview with animation

Can anybody help me with adding subview with animation. I want add subview with animation like CATransition, but with this class we have only several different animation type. But i looking for ability implement it's own animation - different part of view appearing in different time.

Maybe there is exists some examples or something else

Upvotes: 2

Views: 1187

Answers (2)

David Gray
David Gray

Reputation: 307

for UIView Animations:

[newView setFrame:CGRectMake( 0.0f, 480.0f, 320.0f, 480.0f)]; //notice this is OFF screen!
[UIView beginAnimations:@"animateTableView" context:nil];
[UIView setAnimationDuration:0.4];
[newView setFrame:CGRectMake( 0.0f, 0.0f, 320.0f, 480.0f)]; //notice this is ON screen!
[UIView commitAnimations];

There are also build in animations as flip and curl:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
                           forView:newView
                            cache:YES];

[self.navigationController.view addSubview:settingsView.view];
[UIView commitAnimations];

here some more:

Upvotes: 1

arvind
arvind

Reputation: 386

You have to implement this code for add subview with animation

 new_view.hidden=NO;

    CATransition *transition=[CATransition animation];
    transition.type=kCATransitionPush;
    transition.subtype=kCATransitionFromTop;
    transition.duration=0.10;
    [[new_view layer] addAnimation:transition forKey:@"animation2"];

Upvotes: 1

Related Questions