失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 微信摇一摇插件ios_iOS-仿微信摇一摇

微信摇一摇插件ios_iOS-仿微信摇一摇

时间:2023-03-31 15:42:02

相关推荐

微信摇一摇插件ios_iOS-仿微信摇一摇

释放双眼,带上耳机,听听看~!

//

// ViewController.m

// 摇一摇

//

// Created by ZFJ_APPLE on 16/1/25.

// Copyright © 张福杰. All rights reserved.

//

#import "ViewController.h"

#import "LZAudioTool.h"

#import

#define kWidth [UIScreen mainScreen].bounds.size.width

#define kHeight [UIScreen mainScreen].bounds.size.height

@interface ViewController ()

@property (nonatomic,strong) UIImageView *upImage; //背景图片

@property (nonatomic,strong) UIImageView *downImage; //上一半手的图片

@property (nonatomic,strong) UIView *upView; //下一半手

@property (nonatomic,strong) UIView *downView; //下一半手的图片

@end

@implementation ViewController

- (void)viewDidLoad

{

[superviewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

[self uiConfig];

}

- (void)uiConfig

{

UIImageView *image = [[UIImageViewalloc]initWithFrame:CGRectMake(0,kHeight / 4,kWidth, kHeight /2)];

image.image = [UIImageimageNamed:@"ShakeHideImg_women@2x.png"];

[self.viewaddSubview:image];

_upView = [[UIView alloc]initWithFrame:CGRectMake(0,0, kWidth, kHeight / 2)];

_upView.backgroundColor = [UIColor blackColor];

_upImage = [[UIImageView alloc]initWithFrame:CGRectMake(50, kHeight /4, kWidth - 100, kHeight /4)];

_upImage.image = [UIImage imageNamed:@"Shake_Logo_Up@2x.png"];

[_upView addSubview:_upImage];

[self.view addSubview:_upView];

_downView = [[UIView alloc]initWithFrame:CGRectMake(0, kHeight /2, kWidth, kHeight / 2)];

_downView.backgroundColor = [UIColor blackColor];

_downImage = [[UIImageView alloc]initWithFrame:CGRectMake(50,0, kWidth - 100, kHeight /4)];

_downImage.image = [UIImage imageNamed:@"Down@2x.png"];

[_downView addSubview:_downImage];

[self.view addSubview:_downView];

}

#pragma mark - 开始摇晃就会调用

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

//开始摇晃设置动画

[UIView animateWithDuration:1 animations:^{

_upView.frame = CGRectMake(0, -(kHeight /4), kWidth, kHeight / 2);

} completion:^(BOOL finished) {

[UIView animateWithDuration:1 animations:^{

_upView.frame = CGRectMake(0, 0, kWidth, kHeight / 2);

}];

}];

[UIView animateWithDuration:1 animations:^{

_downView.frame = CGRectMake(0, kHeight /2 + kHeight / 4, kWidth, kHeight /2);

} completion:^(BOOL finished) {

[UIView animateWithDuration:1 animations:^{

_downView.frame = CGRectMake(0, kHeight /2, kWidth, kHeight / 2);

}];

}];

//播放摇晃声音

[LZAudioTool playMusic:@"1.mp3"];

}

#pragma mark - 摇晃结束就会调用

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

//摇晃结束

}

#pragma mark - 摇晃被打断就会调用

- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

//摇晃被打断

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

如果觉得《微信摇一摇插件ios_iOS-仿微信摇一摇》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。