核心動畫與UIView
阿新 • • 發佈:2017-06-28
options ima span 沒有 ont nop mea 類型 dap
UIView與核心動畫區別?(掌握) 1.核心動畫只作用在layer. 2.核心動畫看到的都是假像,它並沒有去修改UIView的真實位置. 什麽時候使用核心動畫? 1.當不需要與用戶進行交互,使用核心動畫 2.當要根據路徑做動畫時,使用核心動畫:CABasicAnimation,CAKeyFrameAnimation,兩個都可以根據繪制的路徑UIBizerPath來繪制路徑來執行動畫 3.當做轉場動畫時, 使用核心動畫 (核心動畫轉場類型比較多)CATrasition或是UIView的核心動畫
UIView動畫
1、從屏幕外飛入效果(button可點擊,三個按鈕依次出現)
這段代碼加到viewDidAppear中
CGPoint accountCenter =firstBtn.center;
CGPoint psdCenter = secondBtn.center;
accountCenter.x -= 600;
psdCenter.x -= 600;
firstBtn.center = accountCenter;
secondBtn.center = psdCenter;
//還原中心坐標
accountCenter.x += 600;
psdCenter.x += 600;
[UIView animateWithDuration: 0.5 animations: ^{
firstBtn.center = accountCenter;
} completion: nil];
//delay據firstBtn0.35s後開始動畫 options:可以多參數
[UIView animateWithDuration: 0.5 delay: 0.35 options:
UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionAutoreverse
animations: ^{
secondBtn.center = psdCenter;
} completion: ^(BOOL finished) {
thirdBtn.alpha=1;
}];
核心動畫與UIView