views:

773

answers:

3

Hello, I just want to realize a simple animation, where a picture is faded in a few seconds after the beginning of the application and then it should be faded out and totally disappear. I've never done any animations on the iPhone so I'm stuck. When using something like image.opacity = 1.0; like in the Developer Documentation I get: error: request for member 'opacity' in something not a structure or union. Help would really be appreciated. Greetings Ken

+2  A: 

To fade out an image, you want code like:

[UIView beginAnimations];
myImageView.opacity = 0.0;
[UIView commitAnimations];

You're not setting the opacity of the image itself so much as the opacity of the UIImageView (in this example myImageView) containing the image. You can also control the duration of the animation by adding a line:

[UIView setAnimationDuration: 1.5];

between the calls to -beginAnimations and -commitAnimations.

Fraser Speirs
+1  A: 

What you are looking for is the property "alpha", as in view.alpha. You have simply been looking for the wrong name.

Legal alpha values are from 0.0 (fully transparent) to 1.0 (fully opaque). It will do exactly what you are looking for.

Use the beginAnimations/commitAnimations paradigm referenced in the comment above.

Amagrammer
A: 

It's true. I had to use the myImage.alpha method.Thank you very much!