I am working on a notification system in my iPhone game and want an image to pop up on the screen and automatically fade after 2 seconds.
- User clicks a button that calls the method “popupImage”
- An image appears on the screen in a designated spot, it doesn’t need to fade in
- The image fades out by itself after being on the screen for 2 seconds.
Is there any way of doing this? Thanks ahead of time.
Use
UIViewdedicated methods for that.So imagine you already have your
UIImageViewready, already created and added to the main view, but simply hidden. Your method simply need to make it visible, and start an animation 2 seconds later to fade it out, by animating its “alpha” property from 1.0 to 0.0 (during a 0.5s animation):Simple as that!