仿微信摇一摇 ios
来源:互联网 发布:淘宝2015年销售额 编辑:程序博客网 时间:2024/06/14 20:20
iOS 中有摇动要实现的方法:
- (void)motionBegan:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
- (void)motionEnded:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(nullable UIEvent *)event NS_AVAILABLE_IOS(3_0);
//可以晃动
[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];
//成为第一响应
[self becomeFirstResponder];
//然后去实现那几个方法就可以了
- (void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//检测到摇动
NSLog(@"开始摇动");
//振动效果
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
//让upImageView上移
CABasicAnimation *upAnimation = [CABasicAnimationanimationWithKeyPath:@"position.y"];
upAnimation.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
upAnimation.fromValue = @([UIScreen mainScreen].bounds.size.height/4);
upAnimation.toValue = @(0);
upAnimation.duration = 1;
upAnimation.repeatCount = 1;
upAnimation.autoreverses = YES;
[self.upImageView.layer addAnimation:upAnimation forKey:@"upAnimation"];
//让downImageView下移
CABasicAnimation *downAnimation = [CABasicAnimationanimationWithKeyPath:@"position.y"];
downAnimation.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
downAnimation.fromValue = @([UIScreen mainScreen].bounds.size.height/4*3);
downAnimation.toValue = @([UIScreen mainScreen].bounds.size.height);
downAnimation.duration = 1;
downAnimation.repeatCount = 1;
downAnimation.autoreverses = YES;
[self.downImageView.layer addAnimation:downAnimation forKey:@"downAnimation"];
}
- (void) motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//摇动取消
NSLog(@"取消摇动");
}
- (void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//摇动结束
NSLog(@"摇动结束");
[self.activity stopAnimating ];
if (event.subtype == UIEventSubtypeMotionShake) {
//something happens
}
}
- IOS 仿微信摇一摇
- iOS 仿微信摇一摇
- 仿微信摇一摇 ios
- iOS-OC-仿微信摇一摇
- iOS
- iOS
- IOS
- iOS
- iOS
- IOS
- ios
- iOS
- iOS
- IOS
- iOS
- ios
- ios ~~~~~
- ios
- 5.7 隐藏列表,点击出现 P154
- Servlet开发(一)
- android_监听事件
- 设备分配
- CSS3之利用选择器和content属性在页面中插入内容
- 仿微信摇一摇 ios
- 文件下载(断点续传)——dataTask
- Android中的服务Service初步(1)
- Python学习笔记之简单文件操作
- 如何让标题自带头条属性,请看过来!
- 数组引用:C++ 数组做参数 深入分析
- JAVA POI 读取2013 EXCEL时 XSSFWorkbook(fis);出错
- 连接超时:连接。如果你在一个HTTP代理,请配置IDE或Gradle代理设置
- hbase安装流程