ref1view.hidden = NO;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.25f];
[ref1view setAlpha:([ref1view alpha] == 1.0f) ? 0.0f : 1.0f];
[UIView commitAnimations];
Can anyone please give me a breakdown of how this works? Specifically this line:
[ref1view setAlpha:([ref1view alpha] == 1.0f) ? 0.0f : 1.0f];
It seems that this function will animate the alpha from 0-1 and back from 1-0 and I just don’t understand the syntax.
Thanks!
[ref1view setAlpha:([ref1view alpha] == 1) ? 0.0f : 1.0f];:Sets the alpha of
ref1viewto be 1 if it’s 0, or 0 if it’s 1. This is called the ternary operator, a shorthandif-else.