摇一摇
来源:互联网 发布:怎么延长淘宝收货时间 编辑:程序博客网 时间:2024/05/16 06:07
你可以摇一摇请求鸡汤也可以摇一摇分享,只要在摇一摇的方法里面做你想做的事情就好了
//
// ViewController.m
// yaoyiyao
//
// Created by CJW on 16/7/19.
// Copyright © 2016年 cjw. All rights reserved.
//
#import "ViewController.h"
#import <AudioToolbox/AudioToolbox.h>
#import "UIView+DCAnimationKit.h"
@interface ViewController ()
@property (nonatomic,strong)UIImageView * shakeImageView;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
self.view.backgroundColor = [UIColorredColor];
/***添加支持摇晃**/
[UIApplicationsharedApplication].applicationSupportsShakeToEdit =YES;
[selfbecomeFirstResponder];
self.navigationItem.title =@"JJ天天摇";
//添加图片
UIImageView * imageV = [[UIImageViewalloc]initWithFrame:CGRectMake(100,100, 198,198)];
imageV.image = [UIImageimageNamed:@"摇一摇.png"];
[self.viewaddSubview:imageV];
self.shakeImageView = imageV;
}
//摇一摇方法
-(BOOL)canBecomeFirstResponder
{
returnYES;
}
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"JJ摇动了");
//振动
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
//摇动(用到的第三放的 DCAnimationKit封装)
[self.shakeImageViewmoveRotation:-40duration:0.1finished:^{
[self.shakeImageViewmoveRotation:80duration:0.2finished:^{
[self.shakeImageViewmoveRotation:-60duration:0.2finished:^{
[self.shakeImageViewmoveRotation:60duration:0.3finished:^{
[self.shakeImageViewmoveRotation:-60duration:0.3finished:^{
[self.shakeImageViewmoveRotation:20duration:0.4finished:^{
}];
}];
}];
}];
}];
}];
}
//取消摇动
-(void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"取消摇");
}
//结束摇(在这个方法里面请求你要请求的接口)
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"结束摇");
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- 摇一摇
- 摇一摇
- 摇一摇。。
- 摇一摇
- 摇一摇
- 摇一摇
- 摇一摇
- 摇一摇
- 摇一摇
- 摇一摇
- 摇一摇
- 摇一摇
- 摇一摇
- 摇一摇
- Android摇一摇
- iOS摇一摇
- “摇一摇”功能
- 摇一摇看电影
- hibernate延迟加载(get和load的区别)
- js实现鼠标滚轮控制图片缩放效果的方法(转)
- Android studio value 2 (DexIndexOverflowException,OutOfMemoryError,NoClassDefFoundError错误)
- Android—记住密码功能
- 集群技术(转自百度百科)
- 摇一摇
- 数据结构-栈和队列
- MyEclipse中package Exploer不会显示工程文件
- 解耦---Hybrid H5跨平台性思考
- search-a-2d-matrix
- 解决Get和post请求中中文乱码问题
- 【POJ】1026 - Cipher(置换群)
- html5语义化学习
- oracle 替换所有文字中的不匹配字符