How to make a blinking (or flashing) cursor on iphone?

后端 未结 5 1237
抹茶落季
抹茶落季 2020-12-12 17:43

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

5条回答
  •  抹茶落季
    2020-12-12 18:08

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
    animation.keyPath = @"opacity";
    animation.values =  @[ @(0.0),@(0.0),@(1.0), @(1.0)];
    animation.keyTimes = @[ @(0.001),@(0.49),@(0.50), @(1.0)];
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    animation.duration = 1.2;
    animation.autoreverses = NO;
    animation.repeatCount= HUGE;
    [layer addAnimation:animation forKey:@"blink"];
    

提交回复
热议问题