區(qū)別:
1.核心動(dòng)畫(huà)只作用在layer.
2.核心動(dòng)畫(huà)看到的都是假像,它并沒(méi)有去修改UIView的真實(shí)位置.什么時(shí)候使用核心動(dòng)畫(huà)?
1.當(dāng)不需要與用戶進(jìn)行交互,使用核心動(dòng)畫(huà)
2.當(dāng)要根據(jù)路徑做動(dòng)畫(huà)時(shí),使用核心動(dòng)畫(huà)
3.當(dāng)做轉(zhuǎn)場(chǎng)動(dòng)畫(huà)時(shí), 使用核心動(dòng)畫(huà) (核心動(dòng)畫(huà)轉(zhuǎn)場(chǎng)類型比較多)什么時(shí)候使用UIView的動(dòng)畫(huà)?
如果需要與用戶交互就使用UIView的動(dòng)畫(huà).
不需要與用戶交互可以使用核心動(dòng)畫(huà)
// CABasicAnimation *anima1 = [CABasicAnimation animation];
//
// anima1.keyPath = @"position.y";
// anima1.toValue = @300;
//
// anima1.removedOnCompletion = NO;
// anima1.fillMode =kCAFillModeForwards;
// [self.redView.layer addAnimation:anima1 forKey:nil];
NSLog(@"%@", NSStringFromCGRect(self.redView.frame));
[UIView animateWithDuration:1.0 animations:^{
self.redView.center = CGPointMake(100, 300);
} completion:^(BOOL finished) {
NSLog(@"%@", NSStringFromCGRect(self.redView.frame));
}];