I have a UIView added to a view controller. I want to make it blink twice every 5 seconds.
The following code makes the UIView blink on and off every 1 second:
-(void) showHideView{
[UIView animateWithDuration:1
delay:5
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
self.myview.alpha = 0;
}
completion:^(BOOL finished){
[UIView animateWithDuration:1
delay:5
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
self.myview.alpha = 1;
}
completion:nil
];
}
];
}
How can I make the UIView blink twice every 5 seconds? (i.e. a pulse of two blinks)
Since you've flagged this with iOS7, I might suggest keyframe animation:
Tweak total duration (how often the cycle repeats), the relative start times (a % of the total duration), and the relative duration (again, a % of the total duration) as you see fit.
Change both of your delays to zero.
Set both durations to 1.25.
Use a timer to call the method every 2.5 seconds.
How do I use NSTimer?
Edit based on comments:
Use this instead:
Make your timer call timerCallback every 5 seconds.