mark:
iOS那些简单的动画(不定期更新)
[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];
}];
上面这种动画的好处在于动画过程可控,而且还可以用于removeFromSuperview这种特殊的情况。但是麻烦,像这种动画弹出收起的效果要通过set Frame来实现。
//动画
- (void)addAnimationWithCurrentAnimationView:(UIView *)CurrentAnimationView{
CATransition *animation = [CATransition animation];
animation.type = @"push";
animation.subtype = kCATransitionFromTop;
animation.duration = 0.2;
[CurrentAnimationView.layer addAnimation:animation forKey:nil];
}
第二种方法的优点在于效果可选的多,方便使用,缺点是动画不可控。另外要特别注意的是动画view,本身的layer层加动画。比如说我要在keyWindow上add一个subView,那么就是subView的layer加动画而不是keyWindow