How to animate UIView while hiding or unhiding

I want to animate the UIView while hiding or unhiding it.

I have a button which loads the UIView as "view.hidden=FALSE"and I hide it by "view.hidden=TRUE".

Is there a way of hiding/unhiding while animating it?

Answers


Use this : by default put alpha of your view is 0.0.

yourViewObject.alpha = 0.0f;

when you are trying to unhide your view use this:

yourViewObject.hidden = NO;
[UIView animateWithDuration:0.5f
                     animations:^{
                         yourViewObject.alpha = 1.0;

                     } completion:^(BOOL finished) {
                         //Done
                     }];

And at hiding use this

[UIView animateWithDuration:0.5f
                         animations:^{
                             yourViewObject.alpha = 0.0;

                         } completion:^(BOOL finished) {
                             //Done
                               yourViewObject.hidden = YES;
                         }];

I'm not sure what you mean 100% but you can fade out the view like this...

[UIView animateWithDuration:1.0
                 animations:^(){
                     self.view.alpha = 0.0;
                 }
                 completion:nil];

Need Your Help

Addressbook, data structure in PHP (LDAP)

php ldap openldap

I'm writing an addressbook editor with OpenLDAP backend in PHP.

How do I make my background for a div have an opacity but not the text?

html css

I need help making my background-image have an opacity but not the content thats inside the div? How do I do this and what's wrong with my code? I've tried opacty:numbers and this.