Dropdown UITextfield animation - objective-c

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];

Related

Flipping a view that is contained on a view setup

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];

How can I start animating an UILabel from a particular location in iPad?

I need to start animating a UILabel when a button is pressed... the animation should start from the position of the button.
How can I achieve this?
i.e moving label from one end of the screen to another end.
This is acheviced with UIView's animateWithDuration methods, which can be found in the documentation here.
A very simple example which should be called when your button is pressed:
[UIView animateWithDuration:0.5 animations:^{
// set new position of label which it will animate to
myLabel.frame = CGRectMake(x,y,width,height);
}];

Animating Viewcontroller

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];

How to implement the effect of popping up tableview from bottom of screen?

I'm a newbie of Xcode and Objective-c. Recently I wanna do a task about popping up tableviews. When a button is pressed, the tableview should pop up from the bottom of the screen. The tableview will contain just a few items so I don't wanna it occupy full screen. I read the manual and found UIModalPresentationStyle, but it seems not fulfill my requirements. So what's the more accurate methods I can use?
While #Bharat J's answer is correct, those methods are deprecated in iOS 4.0.
The latest and greatest implementation is + (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
Implemented as:
[UIView animateWithDuration:0.5 animations: ^{
tableView.frame = newFrame;
}
];
You can use below code to create an animation block . Set the frame for the table view as (0,480,320,0) When you hit a button change the frame of the table view in the animation block and make it to CGRectMake(0,200,320,280) or something .
[UIView beginAnimations:#"AnimateTableView" context:view];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
tableView.frame = CGRectMake(0, 200 , 320, 280);
[UIView commitAnimations];
The same animation block for hiding it again but with the frame again begin set to CGRectMake(0,480,320,0). This should work in your case .
Another option would be to use a UIActionSheet and add the uitableview as a subview.
Here is a very similar question about how to add a UIPickerview with similar effect.
Add UIPickerView & a Button in Action sheet - How?

UIColor groupTableViewBackgroundColor is transparent

I have a grouped style UITableView on my navigation stack, and when I click on a cell, I push a UIDatePicker onto the stack. The problem is that I want this custom view to have the same background color as my table view.
I tried setting the background color of my custom view like:
datePicker.backgroundColor = [UIColor groupTableViewBackgroundColor];
But this comes out transparent. I also tried modifying the underlying CGColor object to have an alpha of 1.0, which caused the background color to be black.
The following does work as expected:
datePicker.backgroundColor = [UIColor lightGrayColor];
But, of course, this color doesn't quite match the grouped table background color.
Am I going about this all wrong? I found a similar post about this here, but no helpful response.
What do you mean you "push a UIDatePicker onto the stack"? Why dont you try animating the UIDatePicker into view?
when the view loads, create the picker and set the frame off screen, such as
[picker setFrame:CGRectMake(0,960,320,216)];
then instead of "pushing" the picker, animate it into view like:
[UIView beginAnimations:nil context:NULL];
[picker setFrame:CGRectMake(0,200,320,216)];
[UIView commitAnimations];
And when you want to dismiss the picker, just hide it like:
[UIView beginAnimations:nil context:NULL];
[picker setFrame:CGRectMake(0,960,320,216)];
[UIView commitAnimations];
If you need to, you can also add a toolbar with a "done" button to dismiss the picker, works great for me.
If the contents of the picker are going to be displayed on the table, then you can set the frame of the table in that animation sequence. in the first one, make the table half the size (like 150 for my example would work perfect), then in the hide sequence, make the table the original size (415 for this example). And when you hide the picker, call [tableView reloadData]; to refresh the table.