简体   繁体   中英

Objective C - Turn static image on and off after button has been pressed

This is probably extremely easy, but how to do you make an image "flash" for about 10 seconds on and off then remain on in Objective C for iPhone.

I am using it in an IF statement, where if the button is pressed a choice of two images will appear. Once this has happened i want the images to go from hidden to unhidden and back for a few seconds.

Thanks

Dan

You can use a NSTimer in your view controller for this:

Create a timer with an interval of say, 10 sec:

NSTimer *myTimer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(showOrHideImage) userInfo:nil repeats:YES]; 

Then implement a

-(void)showOrHideImage 

In your "showOrHideImage" method, just toggle the hidden property of your UIImageViews.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM