0
这是我的代码。这很简单。我的问题是为什么当主线程做其他事情时,动画仍然存在,文档说主线程可以更新UI。主线程可以在同一时间做两件事情?动画还在,当主线程做其他事情时
可能是GPU使动画?
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *testLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 80, 50)];
testLabel.font = [UIFont systemFontOfSize:15.0f];
testLabel.backgroundColor = [UIColor redColor];
testLabel.text = @"Hello world";
testLabel.adjustsFontSizeToFitWidth = YES;
[self.view addSubview:testLabel];
[UIView animateWithDuration:10
animations:^{
testLabel.frame = CGRectMake(100, 200, 80, 50);
} completion:^(BOOL finished) {
//
}];
[self performSelector:@selector(hello:) withObject:@"hello" afterDelay:2];
}
- (void)hello:(NSString *)hello{
for (int i = 0; i < 100000; i++) {
NSInteger j = i *5;
NSLog(@"%d",j);
}
NSLog(@"%@",hello);
}
谢谢。这就是答案。“这种自动图形加速可以实现高帧率和流畅的动画效果,而不会增加CPU的负担并降低应用程序的速度。” – frank 2014-11-03 06:13:15
@frank不客气。你能接受答案吗? – KudoCC 2014-11-03 08:27:00