Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make a blinking (or flashing) cursor on iphone?
    primarykey
    data
    text
    <p>I'm trying to create a custom "blinking cursor" in UIKit, I've tried as shown below, having 2 functions that basically keep calling each other until the cursor is hidden. But this leads to a nice infinite recursion... for some reason the functions call each other right away, not each half-second as expected.</p> <p>I tried returning if the 'finished' parameter is not YES (by uncommenting the 'if (!ok)' line), but that leads to no animation at all...</p> <p>Any better idea? Did I miss something, is there a much-easier way to make a "blinking cursor"?</p> <pre><code>- (void)onBlinkIn:(NSString *)animationID finished:(BOOL)ok context:(void *)ctx { if (cursorView.hidden) return; //if (!ok) return; [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.5f]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(onBlinkOut:finished:context:)]; cursorView.textColor = [UIColor grayColor]; [UIView commitAnimations]; } - (void)onBlinkOut:(NSString *)animationID finished:(BOOL)ok context:(void *)ctx { if (cursorView.hidden) return; [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.5f]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(onBlinkIn:finished:context:)]; cursorView.textColor = [UIColor clearColor]; [UIView commitAnimations]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload