動(dòng)畫(huà)

mark:
iOS那些簡(jiǎn)單的動(dòng)畫(huà)(不定期更新)

iOS動(dòng)畫(huà)詳解(學(xué)習(xí)動(dòng)畫(huà)看這一篇就夠了)

ios?平移與抖動(dòng)動(dòng)畫(huà)的簡(jiǎn)單實(shí)現(xiàn)

熱門(mén)動(dòng)畫(huà)的集合demo

    [UIView animateWithDuration:.5 delay:0 usingSpringWithDamping:0.6 initialSpringVelocity:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.settingAdreView.frame =CGRectMake(5,(ScreenHeight-64-49)/2-350/2, settingAdreViewW, settingAdreViewH);
    } completion:^(BOOL finished) {
        
    }];
- (void)createGoodsDetailViewWithShoppingType:(XYShoppingType)shoppingType{
    
    XYGoodsDetailView *xycv = [XYGoodsDetailView createXYGoodsDetailViewWithDelegate:self xYGoodsInfo:_xYGoodsInfo allOtherList:_allOtherList shoppingType:shoppingType bannerList:_bannerList xlOrderForm:(XlOrderForm *)_xlOrderForm];
    
    UIWindow *keywindow = [UIApplication sharedApplication].delegate.window;
    //    UIWindow *keywindow = [[UIApplication sharedApplication] keyWindow];
    xycv.frame = [UIScreen mainScreen].bounds;
        [keywindow  addSubview:xycv];
    xycv.blackBackground.alpha=0.0;
    xycv.frame = CGRectMake(0, ScreenHeight, ScreenWidth, ScreenHeight);
    [UIView animateWithDuration:0.3 animations:^(void) {
        xycv.blackBackground.alpha=0.5;
        xycv.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
        //此處可做UIView漸變效果以及飛出效果
    } completion:^(BOOL finished) {
    }];
//    [self addDetailViewWithAnimationWithHolderView:xycv];
}

- (void)childViewRemoveFromSuperview{
    
    self.blackBackground.alpha=0.0;
    [UIView animateWithDuration:0.3 animations:^(void) {
        
        self.frame = CGRectMake(0, ScreenHeight, ScreenWidth, ScreenHeight);
        //此處可做UIView漸變效果以及飛出效果
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];

上面這種動(dòng)畫(huà)的好處在于動(dòng)畫(huà)過(guò)程可控,而且還可以用于removeFromSuperview這種特殊的情況。但是麻煩,像這種動(dòng)畫(huà)彈出收起的效果要通過(guò)set Frame來(lái)實(shí)現(xiàn)。

//動(dòng)畫(huà)
- (void)addAnimationWithCurrentAnimationView:(UIView *)CurrentAnimationView{
    CATransition *animation = [CATransition animation];
    animation.type = @"push";
    animation.subtype = kCATransitionFromTop;
    animation.duration = 0.2;
    [CurrentAnimationView.layer addAnimation:animation forKey:nil];
}

第二種方法的優(yōu)點(diǎn)在于效果可選的多,方便使用,缺點(diǎn)是動(dòng)畫(huà)不可控。另外要特別注意的是動(dòng)畫(huà)view,本身的layer層加動(dòng)畫(huà)。比如說(shuō)我要在keyWindow上add一個(gè)subView,那么就是subView的layer加動(dòng)畫(huà)而不是keyWindow

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容