iOS 动画效果弹出提示视图
2015-12-27 14:11
543 查看
//弹出提示框,增加了动画效果,当animationDirection参数为nil的时候,默认动画方向是从下至上弹出,如果要改变弹出方向,只要改变animationDirection即可
-(void)showAlertContentViewOnKeyWindow:(UIView*)alertView animationDirection:(NSString
*)animationDirection{
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
CGRect bounds =
CGRectMake(0,0,
WIDTH, HEIGHT);
self.grayView = [[UIView alloc]
initWithFrame:bounds];
[keyWindow addSubview:self.grayView];
UIView *converView = [[UIView alloc]
initWithFrame:bounds];
converView.backgroundColor = [UIColor blackColor];
converView.alpha =0.4;
[self.grayView addSubview:converView];
//用于设置弹出视图的动画效果
CATransition *animation = [CATransition animation];
animation.duration =0.3;
animation.timingFunction =UIViewAnimationCurveEaseInOut;
animation.fillMode =kCAFillModeForwards;
animation.type =kCATransitionPush;//还有这几种动画:kCATransitionPush,kCATransitionReveal,kCATransitionFade
if (animationDirection==nil) {
animation.subtype =kCATransitionFromTop;//移动方向:从下至上
}elseif ([animationDirection
isEqualToString:@"RIGHT"]){
animation.type =kCATransitionFade;
animation.subtype =kCATransitionFromRight;//移动方向:从右至左
}
[alertView.layeraddAnimation:animation
forKey:@"animation"];
[self.grayView addSubview:alertView];
}
-(void)showAlertContentViewOnKeyWindow:(UIView*)alertView animationDirection:(NSString
*)animationDirection{
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
CGRect bounds =
CGRectMake(0,0,
WIDTH, HEIGHT);
self.grayView = [[UIView alloc]
initWithFrame:bounds];
[keyWindow addSubview:self.grayView];
UIView *converView = [[UIView alloc]
initWithFrame:bounds];
converView.backgroundColor = [UIColor blackColor];
converView.alpha =0.4;
[self.grayView addSubview:converView];
//用于设置弹出视图的动画效果
CATransition *animation = [CATransition animation];
animation.duration =0.3;
animation.timingFunction =UIViewAnimationCurveEaseInOut;
animation.fillMode =kCAFillModeForwards;
animation.type =kCATransitionPush;//还有这几种动画:kCATransitionPush,kCATransitionReveal,kCATransitionFade
if (animationDirection==nil) {
animation.subtype =kCATransitionFromTop;//移动方向:从下至上
}elseif ([animationDirection
isEqualToString:@"RIGHT"]){
animation.type =kCATransitionFade;
animation.subtype =kCATransitionFromRight;//移动方向:从右至左
}
[alertView.layeraddAnimation:animation
forKey:@"animation"];
[self.grayView addSubview:alertView];
}
相关文章推荐
- GUI - Web前端开发框架
- Android布局的小窍门?
- Web布局连载——两栏固定布局(五)
- 评价ui设计作品好坏的八个标准(界面/交互设计研究)
- Gifski:一个跨平台的高质量 GIF 编码器
- 模仿动画的放大缩小容器
- 样式表CSS布局经验
- css网页布局中注意的几个问题小结
- DL.DT.DD实现左右的布局简单例子第1/2页
- 使用CSS框架布局的缺点和优点小结
- div+CSS网页布局的意义与副作用原因小结第1/2页
- jQuery 1.9.1源码分析系列(十五)动画处理之缓动动画核心Tween
- 为Yahoo! UI Extensions Grid增加内置的可编辑器
- Android编程之代码创建布局实例分析
- Android中ViewFlipper的使用及设置动画效果实例详解
- jQuery实现美观的多级动画效果菜单代码
- Cocos2d-x UI开发之文本类使用实例
- CSS顶级技巧大放送,div+css布局必知
- php判断GIF图片是否为动画的方法
- 谈谈对jquery ui tabs 的理解