IOS实现动画的几种简单方法

时间:2023-03-09 05:58:42
IOS实现动画的几种简单方法

1.使用 NSTimer 来实现

[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(setNeedsDisplay) userInfo:nil repeats:YES];

2.使用 CADisplayLink 来实现

CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)]; 

[link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; 

相关文章