zoukankan      html  css  js  c++  java
  • 微信摇一摇

    本人apem

    微信摇一摇

    -(BOOL)canBecomeFirstResponder
    {
        return YES;
    }
    
    
    -(void)viewDidAppear:(BOOL)animated {
        
        [super viewDidAppear:animated];
        
        [self becomeFirstResponder];
        
    }
    
    
    -(void)viewWillDisappear:(BOOL)animated {
        
        [self resignFirstResponder];
        
        [super viewWillDisappear:animated];
        
    }
    
    #pragma mark - 实现相应的响应者方法
    /** 开始摇一摇 */
    - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
    {
        NSLog(@"motionBegan");
        
        CGFloat offset = self.bg.height/2;
        CGFloat duration = 0.4;
    
        [UIView animateWithDuration:duration animations:^{
            self.up.y -= offset;
            self.down.y += offset;
        }];
        
        
        [LZAudioTool playMusic:@"dance.mp3"];
    }
    
    /** 摇一摇结束(需要在这里处理结束后的代码) */
    - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
    {
        // 不是摇一摇运动事件
        if (motion != UIEventSubtypeMotionShake) return;
        
        NSLog(@"motionEnded");
        CGFloat offset = self.bg.height / 2;
        CGFloat duration = 0.4;
        [UIView animateWithDuration:duration animations:^{
            self.up.y += offset;
            self.down.y -= offset;
        }];
        
    }
    
    /** 摇一摇取消(被中断,比如突然来电) */
    - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
    {
        NSLog(@"motionCancelled");
    }
  • 相关阅读:
    docker底层原理
    搭建docker私有镜像仓库harbor
    docker 网络详解
    从对集合数据去重到Distinct源码分析
    学习笔记(3)centos7 下安装RabbitMQ
    学习笔记(2)centos7 下安装mysql
    学习笔记(1)centos7 下安装nginx
    2.Redis的数据类型
    1.Redis介绍以及安装
    mongoDB的安装和配置
  • 原文地址:https://www.cnblogs.com/apem/p/4655306.html
Copyright © 2011-2022 走看看