I am working on a project were i need to hide the view and when I click on a button the view should appear, its some thing like animating the view in one view controller?
Thanks.
when clicking a button you will call a method, so in that method write the below code and you hide the view of you added in view. for example if you add a button means remove that.
[button.view removeFromSuperView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self view] cache:YES];
[UIView commitAnimations];
Related
I have several UI elements in a nib that are positioned using autolayout and constraints. When the view loads i move the elements off screen using
[self.button setTransform:CGAffineTransformMakeTranslation(-self.button.frame.origin.x * 2 + self.button.frame.size.width, 0)];
then when the view appears i use the following to ease the button into the correct position on the page. However it seems to move too far across.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:2];
[self.button setTransform:CGAffineTransformIdentity];
[UIView commitAnimations];
Am i doing something wrong? Is there a better way to move the button off the screen with CGAffineTransform?
Any help would be great
The issue was caused by autolayout and the best way to animate UI elements when using autolayout is to change the constraints
Currently I have a "sign up with email" button that hides and shows a view containing 3 UITextfields when clicked.
- (IBAction)hideButton:(id)sender {
[self.emailSignUp setHidden:YES];
[self.emailView setHidden:NO];
[self.signUp setHidden:NO];}
I'd like to add an animation for the text fields to drop down for when the button is tapped. Is this possible? If it is could you please provide some sample code? Thank you in advance!
You can use one of the Block-based [UIView animationWith...] methods and change the frame of your views or you can do something like[UIView beginAnimations:#"Animation" context:NULL];
// Assumes the your view is just off the bottom of the screen.
self.textView.frame = CGRectOffset(self.textView.frame, 0, -self.TextView.frame.size.height);
[UIView commitAnimations];
I currently have a xib that is a standard view that has another view contained on top. I want the user to be able to click on this subview, and then have this subview flip over when pressed. I currently have code that flips the view around, but since I'm not explicitly assigning a new view, it just flips over and displays the same view. Here is my code when the button is pressed:
- (IBAction)flipCard:(id)sender
{
NSLog(#"Subview button was clicked!");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.frontOfView
cache:YES];
[UIView commitAnimations];
}
The biggest question is how to set this up. Do I need to create an entire view programmatically and then just call [[self view] addSubview: backOfView]*? Or is there a way to do this with interface builder?
*Note I haven't actually create a "backOfView" object, I'm not sure how I should create one at this point.
Try this one?
[UIView transitionFromView:self.frontOfView
toView:self.backOfView
duration:0.4f
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:nil];
I have an uiview which i add a transition that removes it from an uiwindow using curlup animation. When the animation occurs the backside of the view is white...i would like to change the color of it or even put some of my own texture. Any help appreciated.
[UIView beginAnimations: #"Curl up" context:nil];
// wait for time before begin
[UIView setAnimationDelay:wait];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:viewToCurlUp cache:YES];
// druation of animation
[UIView setAnimationDuration:duration];
[UIView commitAnimations];
As far as I know, it is not possible to create a texture (ie: your own image) on a UIView. The color of 'back of the curl' should correspond to the background color you have set for your UIView. You can do this in the inspector in Interface Builder, or programmatically like so:
[view setBackgroundColor:[UIColor greenColor]];
where view is the UIView of interest. Use the appropriate color, of course.
Hope that helps.
Apple engineers responded that this is not possible in my case. I have asked them a few days ago.
When I start a movie in a MPMoviePlayerController, controls stay at the top for few seconds. After that, they fade out.
I want simulate this effect when I use MPMovieControlStyleNone in controlStyle property, but controls disappear abruptly. I tried to use animations without success with the following code:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.50f];
self.myMoviePlayer.controlStyle = MPMovieControlStyleNone;
[UIView commitAnimations];
Someone have any idea how I can make that?
Any help will be appreciated.
Thanks.
If I understand you correctly, you are planning to hide custom controls in a similar fashion to the original controls.
You will need hide your custom controls using something like
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.50];
self.customControlsView.alpha = 0.0f;
[UIView commitAnimations];
to achieve that effect. controlStyle is not an animatable property.
On tops, you will need to stick to controlStyle = MPMovieControlStyleNone anyways throughout the lifetime of your MPMoviePlayerController as that is the only way to prevent the original controls from appearing.