iOS 每日一记之———————————————仿QQ语音通话隐藏显示效果
来源:互联网 发布:苹果mac双系统切换 编辑:程序博客网 时间:2024/05/17 09:30
最近狼人杀要做缩小效果 缩小的效果就和QQ语音聊天点击收起的动态特效是一样的 。。。。。
恩 闲话少说 直接上代码 。。。
#pragma mark -- CA缩小动画效果
- (void)animateDismissTransition:(UIView *)view rect:(CGRect)endRect{
// 1.获取动画缩放结束时的圆形
UIBezierPath *endPath = [UIBezierPath bezierPathWithOvalInRect:endRect];
// 2.获取动画缩放开始时的圆形
CGSize startSize = CGSizeMake(view.frame.size.width * 0.5, view.frame.size.height - ((SCREEN_WIDTH/7.0)/2));
CGFloat radius = sqrt(startSize.width * startSize.width + startSize.height * startSize.height);
CGRect startRect = CGRectInset(endRect, -radius, -radius);
UIBezierPath *startPath = [UIBezierPath bezierPathWithOvalInRect:startRect];
// 3.创建shapeLayer作为视图的遮罩
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = endPath.CGPath;
view.layer.mask = shapeLayer;
self.shapeLayer = shapeLayer;
// 添加动画
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"];
pathAnimation.fromValue = (id)startPath.CGPath;
pathAnimation.toValue = (id)endPath.CGPath;
pathAnimation.duration = 0.8;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.delegate = self;
pathAnimation.removedOnCompletion = NO;
pathAnimation.fillMode = kCAFillModeForwards;
[shapeLayer addAnimation:pathAnimation forKey:@"packupAnimation"];
}
view是在做动画的那个View endRect 是你结束之后的坐标位置
我的View 其实就是我最外层的window
接下来是window的拖拽事件
//window的拖拽手势
- (void)panClick:(UIPanGestureRecognizer*)pan{
if (!_small) {
return;
}
UIApplication *myApplication = [UIApplication sharedApplication];
UIWindow *myKeyWindow = myApplication.keyWindow;
for (UIWindow *showWindow in myApplication.windows) {
if (![showWindow isKindOfClass:NSClassFromString(@"UITextEffectsWindow")]) {
myKeyWindow = showWindow;
CGPoint point = [pan locationInView:myKeyWindow];
CGFloat distance = WCX_SCALE_SCREEN_Height(27); // 离四周的最小边距
if (pan.state == UIGestureRecognizerStateEnded) {
if (point.y <= distance) {
point.y = distance;
} else if(point.y >= [UIScreen mainScreen].bounds.size.height - distance){
point.y = [UIScreen mainScreen].bounds.size.height - distance;
}else if (point.x <= [UIScreen mainScreen].bounds.size.width/2.0) {
point.x = distance;
} else{
point.x = [UIScreen mainScreen].bounds.size.width - distance;
}
[UIView animateWithDuration:0.5 animations:^{
pan.view.center = point;
}];
} else{
pan.view.center = point;
}
windowEndRect = pan.view.frame;
smallViewEndRect = windowEndRect;
}
}
}
最后是单击window的放大事件。。。。
#pragma mark -- CA放大动画
- (void)CATapClick{
AppDelegate *deleage = (AppDelegate *)[UIApplication sharedApplication].delegate;
[UIView animateWithDuration:1.0 animations:^{
} completion:^(BOOL finished) {
//deleage.gameWindow.bounds = [UIScreen mainScreen].bounds;
//deleage.gameWindow.frame = deleage.gameWindow.bounds;
//deleage.gameWindow.layer.cornerRadius =0;
//deleage.gameWindow.layer.masksToBounds = YES;
// 1.获取动画缩放开始时的圆形
CGRect rect;
if (windowEndRect.size.height == 0){
rect = smallViewEndRect;
} else{
rect = windowEndRect;
}
UIBezierPath *startPath = [UIBezierPath bezierPathWithOvalInRect:rect];
// 2.获取动画缩放结束时的圆形
CGSize endSize = CGSizeMake(deleage.gameWindow.frame.size.width * 0.5, deleage.gameWindow.frame.size.height);
CGFloat radius = sqrt(endSize.width * endSize.width + endSize.height * endSize.height);
CGRect endRect = CGRectInset(rect, -radius, -radius);
UIBezierPath *endPath = [UIBezierPath bezierPathWithOvalInRect:endRect];
// 3.创建shapeLayer作为视图的遮罩
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = endPath.CGPath;
deleage.gameWindow.layer.mask = shapeLayer;
self.shapeLayer = shapeLayer;
// 添加动画
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"path"];
pathAnimation.fromValue = (id)startPath.CGPath;
pathAnimation.toValue = (id)endPath.CGPath;
pathAnimation.duration = 0.8;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.delegate = self;
pathAnimation.removedOnCompletion = NO;
pathAnimation.fillMode = kCAFillModeForwards;
[shapeLayer addAnimation:pathAnimation forKey:@"showAnimation"];
}];
}
appdelegate 不需多言了吧 gameWindow就是狼人杀所在的window。。。。恩 这样就行了
- iOS 每日一记之———————————————仿QQ语音通话隐藏显示效果
- jQuery效果(一)——隐藏/显示
- 高仿QQ音乐之旋转专辑图片的实现—仿留声机效果
- Android视频通话(即时通讯)推荐—语音视频
- jQuery效果——显示和隐藏
- iOS 每日一记 之—— application的生命周期
- TCP编程——最简单的QQ通话功能
- Qt 之 QQ系统表情—实现动态显示效果
- iOS——科大讯飞之语音识别
- Android动画开发——Animation显示隐藏菜单效果
- Android动画开发——Animation显示隐藏菜单效果
- jQuery学习(四) 效果——隐藏/显示
- 学徒浅析Android开发:杂谈——仿QQ列表左右滑动效果
- C#仿QQ皮肤—更新DataGridView的鼠标跟随效果
- iOS每日一记 ——————之 友盟页面统计
- iOS每日一记之——————iOS9系统策略更新
- iOS每日一记——————之简单的去重操作。。。。
- iOS开发(OC)——QQ点赞效果
- Java设计模式之模板方法模式
- android build 编译打印详细过程
- JDBC链接oracle12c 出现 ora-28040: no matching authentication protocol
- 输入输出外挂总结
- caffe入门3:利用imagenet在caffe上训练自己的数据集
- iOS 每日一记之———————————————仿QQ语音通话隐藏显示效果
- Android Memory Analyzer Tool(MAT) 使用基础
- rownum 用法
- fun.js
- JUnit之JUnitCore详解
- 看看特斯拉汽车使用的是什么电池(18650)
- linux du查看某个文件或目录占用磁盘空间的大小
- iOS 开发之给UILabel 或者 UIButton标题加下划线
- Android反编译工具的使用-Android Killer