最近狼人杀要做缩小效果 缩小的效果就和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语音通话隐藏显示效果相关推荐

  1. iOS每日一记------------之 中级完美大整理

    iOS.mac开源项目及库汇总 UI 下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅 ...

  2. iOS每日一记之———————————————终级完美大整理

    iOS.mac开源项目及库汇总 UI 下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅 ...

  3. ios音乐播放器-仿QQ音乐

    这篇文章主要写一个iOS系统下的音乐播放器 , 包括简单的仿QQ音乐播放器界面.音乐播放.歌词解析.后台控制等  ,如果你正好需要 , 希望你看完后能够对你的提升有所帮助 , 当然,阅读中如果发现什么 ...

  4. 仿QQ语音变声功能实现

    版权声明:转载必须注明本文转自张鹏辉的博客: http://blog.csdn.net/qingtiangg 大家好,这是我从业以来第一篇博客,给大家拜个晚年,祝大家鸡年大吉,幸福美满.事业有成.好了 ...

  5. python控制qq语音通话_懒人专用的奇淫技巧,用Python实现炫酷的语音操作电脑!...

    最近小编忙里偷闲的看了一部电影叫做<头号玩家>,虽然当时去电影院观看了,但是现在回看之后依然是感觉很过瘾,里面的虚拟现实让人看着非常的真实.小编也想过一把这种科幻的瘾. 虽然电影里的效果我 ...

  6. android变声后的文件,仿QQ语音变声功能实现(二)---移植到android studio 并解决部分问题...

    版权声明:转载必须注明本文转自张鹏辉的博客: http://blog.csdn.net/qingtiangg 大家好,距离上一篇博客半年过去了,关于上一篇博客很多人加我QQ留言问了几个问题,最近不忙决 ...

  7. 仿QQ语音变声功能实现(二)---移植到android studio 并解决部分问题

    版权声明:转载必须注明本文转自张鹏辉的博客: http://blog.csdn.net/qingtiangg 大家好,距离上一篇博客半年过去了,关于上一篇博客很多人加我QQ留言问了几个问题,最近不忙决 ...

  8. iOS开发手记-仿QQ音乐播放器动态歌词的实现

    最近朋友想做个音乐App,让我帮忙参考下.其中歌词动态滚动的效果,正好我之前也没做过,顺便学习一下,先来个预览效果. 实现思路 歌词常见的就是lrc歌词了,我们这里也是通过解析lrc歌词文件来获取其播 ...

  9. iOS每日一记之———————————————面试杂感。。。。 6月3号到6月14号

    6月3号 下午   学乐中国 面试内容: block MBprogressHUD Xib约束问题 链式编程问题 KVO KVC 大隐  因为没技术面试 暂不评论 6月4号 七元  貌似在什么阿里百川创 ...

  10. Android 仿QQ语音录制 竖线波纹效果

    源码如下: https://github.com/xf420811/audiorecord 效果图

最新文章

  1. ASP编程常用的函数function集合
  2. 讯飞输入法有没有Linux,Debian testing 安装讯飞输入法 - Linux系统与应用 - LinuxApp - 水木社区...
  3. 基于STM32和W5500的Modbus TCP通讯
  4. 备份自己常用的VS2010设置
  5. JPA getValidationMode()
  6. 谈谈lucene的DocValues特性之SortedNumericDocValuesField
  7. a标签download属性无效_使用这些 CSS 属性选择器来提高前端开发效率
  8. PLSQL Developer 12 破解注册码(64位)
  9. 2018年腾讯校招产品群面体会
  10. 总结:服务网格(Service Mesh)
  11. 墨画子卿第一章第4节:世界观的颠覆
  12. 5W无线充SOC方案芯片FS68001封装SOP16和SOP8
  13. 海思Hi3516dv300屏幕调试MIPI TX接口LCD屏幕(京东方JD9366)
  14. 【数据库】数据库恢复技术
  15. 软件开发知识点基础介绍
  16. 嵌入式跑马灯实验报告linux,ARM嵌入式跑马灯设计实验报告.doc
  17. statuml怎么添加用户_starUML用户使用手册
  18. 揭开小额信贷业务系统的秘密
  19. python 第七周
  20. 专题一:欧拉视频放大(线性)------MATLAB代码解析(一.maxPyrHt(imsz,filtsz))

热门文章

  1. ubuntu hashcat 安装
  2. 如何制作千人千面的NFT?如何存储NFT?#Crystals #nft.storage #ipfs
  3. setcpu_SetCpu Android超频工具
  4. HTML5酷炫动画集锦
  5. codeforces 1077E Thematic Contests
  6. Linux TCP之sack(二)
  7. w10控制面板卸载java_手把手教你解决Win10控制面板无法卸载软件的问题
  8. 重装系统备份找不到镜像文件_如何从Windows 7系统映像备份中提取单个文件
  9. 用java制作扑克牌_java实现简单扑克牌游戏
  10. html编写扑克牌游戏,用js编写扑克牌小游戏