Suppose you have a UIView instance in the UIViewController class like this:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(x, y, w1, h1)];
[self.view addSubview:view];
based on the requirement you set the view visibility as I did here .. I am not displaying the view when the controller is loading it's view ..
[view setHidden:YES];
Maintain a flag to check the visibility of the view instance .. lets say isViewVisible
is my flag to check the visibility of the view .. I set it to NO in the begning ..
isHelpViewVisible = NO;
and I wrote an action method (viewClicked) here to expand and to collapse the view object , give this action method to a button instance and it will work.
- (void)viewClicked:(id)sender {
if (!isViewVisible) {
isViewVisible = YES;
[view setHidden:NO];
[UIView beginAnimations:@"animationOff" context:NULL];
[UIView setAnimationDuration:1.3f];
[view setFrame:CGRectMake(x, y, w1, h1)];
[UIView commitAnimations];
} else {
isViewVisible = NO;
[view setHidden:NO];
[UIView beginAnimations:@"animationOff" context:NULL];
[UIView setAnimationDuration:1.3f];
[view setFrame:CGRectMake(x, y, width, hight)];
[UIView commitAnimations];
}
}
and add the textfields and labels objects to the view object as subviews and set the animation to those objects as well .. it will work.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…