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