未验证 提交 467f8670 编写于 作者: W WangLao100 提交者: GitHub

Merge pull request #865 from WangLao100/feature/ios-mc

替换图片icon , fix  UITextView  一机多控。 增加其他手势的测试用例
......@@ -5,12 +5,11 @@
"scale" : "1x"
},
{
"filename" : "doraemon_logo@2x.png",
"filename" : "dk_doraemon.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "doraemon_logo@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
......@@ -57,6 +57,9 @@
@property (nonatomic , assign) CGPoint do_mc_temp_location;
@property (nonatomic , assign) CGPoint do_mc_host_temp_p;
@property (nonatomic , assign) CGPoint do_mc_temp_Vol;
@end
......
......@@ -266,8 +266,8 @@
@end
@implementation UITextField (support)
@implementation UIControl (support)
+ (void)load {
static dispatch_once_t onceToken;
......@@ -298,8 +298,7 @@
if (![DoraemonMCServer isOpen]) {
return;
}
if (![self isKindOfClass:[UITextField class]] &&
![self isKindOfClass:[UITextView class]]) {
if (![self isKindOfClass:[UITextField class]]) {
return;
}
......@@ -316,6 +315,52 @@
@end
@implementation UITextView (support)
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[self do_mc_swizzleInstanceMethodWithOriginSel:@selector(initWithFrame:) swizzledSel:@selector(do_mc_initWithFrame:)];
});
}
- (instancetype)do_mc_initWithFrame:(CGRect)frame {
id instance = [self do_mc_initWithFrame:frame];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(do_mc_sendTextViewPayload:) name:UITextViewTextDidChangeNotification object:nil];
return instance;
}
- (void)do_mc_sendTextViewPayload:(NSDictionary*(^)(NSDictionary*))payload {
if (![DoraemonMCServer isOpen]) {
return;
}
if (![self isKindOfClass:[UITextView class]]) {
return;
}
[DoraemonMCCommandGenerator sendMessageWithView:self
gusture:nil
action:nil
indexPath:nil
messageType:DoraemonMCMessageTypeTextInput];
}
@end
@interface UITableView (DoraemonMCSupport)
@end
......
......@@ -155,7 +155,7 @@
}
}
if ([rootView isKindOfClass:[UITextField class]]) {
if ([rootView isKindOfClass:[UITextView class]]) {
UITextView *tVView = (UITextView *)rootView ;
if (data[@"text"]) {
......
......@@ -8,6 +8,12 @@
/* Begin PBXBuildFile section */
0977CCE0269F394100A6463E /* DoraemonDemoMultiControlViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0977CCDF269F394000A6463E /* DoraemonDemoMultiControlViewController.m */; };
09B042C526A8585500045D2A /* DoraemonDemoMultiConLongPressGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 09B042C426A8585500045D2A /* DoraemonDemoMultiConLongPressGesture.m */; };
09B042C926A860B400045D2A /* DoraemonDemoMultiConPinchGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 09B042C826A860B400045D2A /* DoraemonDemoMultiConPinchGesture.m */; };
09B042CD26A8760E00045D2A /* DoraemonDemoMultiConRotationGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 09B042CC26A8760E00045D2A /* DoraemonDemoMultiConRotationGesture.m */; };
09B042D126A8777900045D2A /* DoraemonDemoMultiConSwipeGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 09B042D026A8777900045D2A /* DoraemonDemoMultiConSwipeGesture.m */; };
09B042D526A877ED00045D2A /* DoraemonDemoMultiConScreenEdgePanGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 09B042D426A877ED00045D2A /* DoraemonDemoMultiConScreenEdgePanGesture.m */; };
09B042D926A8781A00045D2A /* DoraemonDemoMultiConTapGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 09B042D826A8781A00045D2A /* DoraemonDemoMultiConTapGesture.m */; };
0A5399852349ED5B00C47CB3 /* DoraemonDemoMemoryLeakViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A5399842349ED5B00C47CB3 /* DoraemonDemoMemoryLeakViewController.m */; };
0A5399882349EE7E00C47CB3 /* DoraemonDemoMemoryLeakModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A5399872349EE7E00C47CB3 /* DoraemonDemoMemoryLeakModel.m */; };
0A53998B2349EE9500C47CB3 /* DoraemonDemoMemoryLeakView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A53998A2349EE9500C47CB3 /* DoraemonDemoMemoryLeakView.m */; };
......@@ -51,6 +57,18 @@
/* Begin PBXFileReference section */
0977CCDE269F394000A6463E /* DoraemonDemoMultiControlViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoraemonDemoMultiControlViewController.h; sourceTree = "<group>"; };
0977CCDF269F394000A6463E /* DoraemonDemoMultiControlViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DoraemonDemoMultiControlViewController.m; sourceTree = "<group>"; };
09B042C326A8585500045D2A /* DoraemonDemoMultiConLongPressGesture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoraemonDemoMultiConLongPressGesture.h; sourceTree = "<group>"; };
09B042C426A8585500045D2A /* DoraemonDemoMultiConLongPressGesture.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DoraemonDemoMultiConLongPressGesture.m; sourceTree = "<group>"; };
09B042C726A860B400045D2A /* DoraemonDemoMultiConPinchGesture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoraemonDemoMultiConPinchGesture.h; sourceTree = "<group>"; };
09B042C826A860B400045D2A /* DoraemonDemoMultiConPinchGesture.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DoraemonDemoMultiConPinchGesture.m; sourceTree = "<group>"; };
09B042CB26A8760E00045D2A /* DoraemonDemoMultiConRotationGesture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoraemonDemoMultiConRotationGesture.h; sourceTree = "<group>"; };
09B042CC26A8760E00045D2A /* DoraemonDemoMultiConRotationGesture.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DoraemonDemoMultiConRotationGesture.m; sourceTree = "<group>"; };
09B042CF26A8777900045D2A /* DoraemonDemoMultiConSwipeGesture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoraemonDemoMultiConSwipeGesture.h; sourceTree = "<group>"; };
09B042D026A8777900045D2A /* DoraemonDemoMultiConSwipeGesture.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DoraemonDemoMultiConSwipeGesture.m; sourceTree = "<group>"; };
09B042D326A877ED00045D2A /* DoraemonDemoMultiConScreenEdgePanGesture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoraemonDemoMultiConScreenEdgePanGesture.h; sourceTree = "<group>"; };
09B042D426A877ED00045D2A /* DoraemonDemoMultiConScreenEdgePanGesture.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DoraemonDemoMultiConScreenEdgePanGesture.m; sourceTree = "<group>"; };
09B042D726A8781A00045D2A /* DoraemonDemoMultiConTapGesture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoraemonDemoMultiConTapGesture.h; sourceTree = "<group>"; };
09B042D826A8781A00045D2A /* DoraemonDemoMultiConTapGesture.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DoraemonDemoMultiConTapGesture.m; sourceTree = "<group>"; };
0A5399832349ED5B00C47CB3 /* DoraemonDemoMemoryLeakViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoraemonDemoMemoryLeakViewController.h; sourceTree = "<group>"; };
0A5399842349ED5B00C47CB3 /* DoraemonDemoMemoryLeakViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DoraemonDemoMemoryLeakViewController.m; sourceTree = "<group>"; };
0A5399862349EE7E00C47CB3 /* DoraemonDemoMemoryLeakModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DoraemonDemoMemoryLeakModel.h; sourceTree = "<group>"; };
......@@ -142,6 +160,18 @@
children = (
0977CCDE269F394000A6463E /* DoraemonDemoMultiControlViewController.h */,
0977CCDF269F394000A6463E /* DoraemonDemoMultiControlViewController.m */,
09B042C326A8585500045D2A /* DoraemonDemoMultiConLongPressGesture.h */,
09B042C426A8585500045D2A /* DoraemonDemoMultiConLongPressGesture.m */,
09B042C726A860B400045D2A /* DoraemonDemoMultiConPinchGesture.h */,
09B042C826A860B400045D2A /* DoraemonDemoMultiConPinchGesture.m */,
09B042CB26A8760E00045D2A /* DoraemonDemoMultiConRotationGesture.h */,
09B042CC26A8760E00045D2A /* DoraemonDemoMultiConRotationGesture.m */,
09B042CF26A8777900045D2A /* DoraemonDemoMultiConSwipeGesture.h */,
09B042D026A8777900045D2A /* DoraemonDemoMultiConSwipeGesture.m */,
09B042D326A877ED00045D2A /* DoraemonDemoMultiConScreenEdgePanGesture.h */,
09B042D426A877ED00045D2A /* DoraemonDemoMultiConScreenEdgePanGesture.m */,
09B042D726A8781A00045D2A /* DoraemonDemoMultiConTapGesture.h */,
09B042D826A8781A00045D2A /* DoraemonDemoMultiConTapGesture.m */,
);
path = MultiControl;
sourceTree = "<group>";
......@@ -576,14 +606,20 @@
DAFE052C21BD4A4D00F97A59 /* DoraemonDemoCommonViewController.m in Sources */,
0AFBC55223BAE6F80099A8BD /* DoraemonDemoNetTableViewCell.m in Sources */,
0AA262E1240F8AC400BF144F /* DoraemonDemoBaseViewController.m in Sources */,
09B042D526A877ED00045D2A /* DoraemonDemoMultiConScreenEdgePanGesture.m in Sources */,
DAFE052A21BD4A4D00F97A59 /* DoraemonDemoCrashMRCView.m in Sources */,
0A6CF27C2438BDDD00A2CBF4 /* DoraemonKitDemoi18Util.m in Sources */,
09B042C926A860B400045D2A /* DoraemonDemoMultiConPinchGesture.m in Sources */,
09B042CD26A8760E00045D2A /* DoraemonDemoMultiConRotationGesture.m in Sources */,
DAC3FA7622B8DD7400871E5C /* DoraemonDemoImageViewController.m in Sources */,
09B042C526A8585500045D2A /* DoraemonDemoMultiConLongPressGesture.m in Sources */,
09B042D926A8781A00045D2A /* DoraemonDemoMultiConTapGesture.m in Sources */,
DAC3FA7922B8E0EE00871E5C /* DoraemonDemoImageShowViewController.m in Sources */,
DAC8A87C1FDE2C3B00F03E6F /* DoKitAppDelegate.m in Sources */,
DAFE052821BD4A4D00F97A59 /* DoraemonDemoLoggerViewController.m in Sources */,
DAFE052E21BD4A4D00F97A59 /* DoraemonDemoMockGPSViewController.m in Sources */,
DAFE052F21BD4A4D00F97A59 /* DoraemonDemoPerformanceViewController.m in Sources */,
09B042D126A8777900045D2A /* DoraemonDemoMultiConSwipeGesture.m in Sources */,
0A6C9CED2423219400BAEF5E /* DoraemonDemoURLProtocol2.m in Sources */,
0A53998B2349EE9500C47CB3 /* DoraemonDemoMemoryLeakView.m in Sources */,
DAFE052521BD4A4D00F97A59 /* DoraemonDemoUIViewController.m in Sources */,
......@@ -735,14 +771,14 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 46A29A7ADN;
DEVELOPMENT_TEAM = 7M2BQXS6D5;
ENABLE_BITCODE = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "DoraemonKitDemo/DoraemonKitDemo-PrefixHeader.pch";
INFOPLIST_FILE = DoraemonKitDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.didi.dokit.demo.lth;
PRODUCT_BUNDLE_IDENTIFIER = com.didi.dokit.demo.123;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
TARGETED_DEVICE_FAMILY = "1,2";
......@@ -756,14 +792,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 46A29A7ADN;
DEVELOPMENT_TEAM = 7M2BQXS6D5;
ENABLE_BITCODE = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "DoraemonKitDemo/DoraemonKitDemo-PrefixHeader.pch";
INFOPLIST_FILE = DoraemonKitDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.didi.dokit.demo.lth;
PRODUCT_BUNDLE_IDENTIFIER = com.didi.dokit.demo.123;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
TARGETED_DEVICE_FAMILY = "1,2";
......
//
// DoraemonDemoMultiConLongPressGesture.h
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoBaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface DoraemonDemoMultiConLongPressGesture : DoraemonDemoBaseViewController
@end
NS_ASSUME_NONNULL_END
//
// DoraemonDemoMultiConLongPressGesture.m
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoMultiConLongPressGesture.h"
#import "UIView+Doraemon.h"
#import "UIImage+Doraemon.h"
@interface DoraemonDemoMultiConLongPressGesture ()
@property (nonatomic, strong)UIImageView *imageview;
@end
@implementation DoraemonDemoMultiConLongPressGesture
- (void)viewDidLoad {
[super viewDidLoad];
self.title = DoraemonDemoLocalizedString(@"长按事件");
self.imageview.userInteractionEnabled = YES;
[self.view addSubview:self.imageview];
UILongPressGestureRecognizer * longpress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longpress:)];
longpress.minimumPressDuration = 0.5;
longpress.numberOfTapsRequired = 0;
longpress.cancelsTouchesInView = YES;
[self.imageview addGestureRecognizer:longpress];
}
- (UIImageView *)imageview {
if(!_imageview){
CGFloat size = 240;
_imageview = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.doraemon_width - size) / 2.0, size, self.view.doraemon_width, size)];// CGFloat size =
_imageview.image = [UIImage doraemon_xcassetImageNamed:@"doraemon_file_sync_banner"];
}
return _imageview;
}
-(void)longpress:(UILongPressGestureRecognizer *)sender {
[self showAlertMessage];
}
- (void)showAlertMessage{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:[NSString stringWithFormat:@"是否要删除图片"] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *sureAction2 = [UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[self deleteImageAction];
}];
[alertController addAction:sureAction];
[alertController addAction:sureAction2];
[self.navigationController presentViewController:alertController animated:YES completion:nil];
}
- (void)deleteImageAction {
[UIView animateWithDuration:1.0
delay:0.0
options:0
animations:^{
self.imageview.alpha = 0.0;
} completion:^(BOOL finished) {
[self.imageview removeFromSuperview];
}];
}
@end
//
// DoraemonDemoMultiConPinchGesture.h
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoBaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface DoraemonDemoMultiConPinchGesture : DoraemonDemoBaseViewController
@end
NS_ASSUME_NONNULL_END
//
// DoraemonDemoMultiConPinchGesture.m
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoMultiConPinchGesture.h"
#import "UIView+Doraemon.h"
#import "UIImage+Doraemon.h"
@interface DoraemonDemoMultiConPinchGesture ()
@property (nonatomic, strong)UIImageView *imageview;
@property (nonatomic,strong) UIView * backgroundView;
@property (nonatomic) BOOL isLargeView;
@property (nonatomic) CGRect oldFrame;
@end
@implementation DoraemonDemoMultiConPinchGesture
- (void)viewDidLoad {
[super viewDidLoad];
self.title = DoraemonDemoLocalizedString(@"长安事件");
self.imageview.center = self.view.center;
[self.view addSubview:self.imageview];
[self.imageview setUserInteractionEnabled:YES];
UIPinchGestureRecognizer * pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
[self.imageview addGestureRecognizer:pinch];
self.isLargeView = NO;
self.oldFrame = self.imageview.frame;
}
- (UIImageView *)imageview {
if(!_imageview){
CGFloat size = 400;
_imageview = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.doraemon_width - size) / 2.0, size, self.view.doraemon_width, size)];// CGFloat size =
_imageview.image = [UIImage doraemon_xcassetImageNamed:@"doraemon_file_sync_banner"];
}
return _imageview;
}
-(void)pinch:(UIPinchGestureRecognizer *)pinch{
if (pinch.state == UIGestureRecognizerStateRecognized) {
if (!self.isLargeView && pinch.velocity > 0) {
self.backgroundView = [[UIView alloc] initWithFrame:self.view.frame];
self.backgroundView.backgroundColor = [UIColor blackColor];
self.backgroundView.alpha = 0.0;
self.imageview.backgroundColor = [UIColor blueColor];
[self.view insertSubview:self.backgroundView belowSubview:self.imageview];
[UIView animateWithDuration:0.8
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
self.imageview.frame = CGRectMake(0,220,320,210);
}
completion:^(BOOL finished) {
self.isLargeView = YES;
}];
}
if (self.isLargeView && pinch.velocity < 0) {
[UIView animateWithDuration:0.8
animations:^{
self.imageview.frame = self.oldFrame;
}
completion:^(BOOL finished) {
[self.backgroundView removeFromSuperview];
self.backgroundView = nil;
self.isLargeView = NO;
}];
}
}
}
@end
//
// DoraemonDemoMultiConRotationGesture.h
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoBaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface DoraemonDemoMultiConRotationGesture : DoraemonDemoBaseViewController
@end
NS_ASSUME_NONNULL_END
//
// DoraemonDemoMultiConRotationGesture.m
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoMultiConRotationGesture.h"
#import "UIView+Doraemon.h"
#import "UIImage+Doraemon.h"
@interface DoraemonDemoMultiConRotationGesture ()
@property (nonatomic, strong)UIImageView *imageview;
@end
@implementation DoraemonDemoMultiConRotationGesture
- (void)viewDidLoad {
[super viewDidLoad];
self.title = DoraemonDemoLocalizedString(@"旋转手势");
[self.view addSubview:self.imageview];
self.imageview.center = self.view.center;
self.imageview.userInteractionEnabled = YES;
UIRotationGestureRecognizer * rotate = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];
[self.imageview addGestureRecognizer:rotate];
}
- (UIImageView *)imageview {
if(!_imageview){
CGFloat size = 240;
_imageview = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.doraemon_width - size) / 2.0, size, self.view.doraemon_width, size)];// CGFloat size =
_imageview.image = [UIImage doraemon_xcassetImageNamed:@"doraemon_file_sync_banner"];
}
return _imageview;
}
-(void)rotate:(UIRotationGestureRecognizer *)sender{
if (sender.state == UIGestureRecognizerStateChanged) {
self.imageview.transform = CGAffineTransformMakeRotation(sender.rotation);
}
}
@end
//
// DoraemonDemoMultiConScreenEdgePanGesture.h
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoBaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface DoraemonDemoMultiConScreenEdgePanGesture : DoraemonDemoBaseViewController
@end
NS_ASSUME_NONNULL_END
//
// DoraemonDemoMultiConScreenEdgePanGesture.m
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoMultiConScreenEdgePanGesture.h"
#import "UIView+Doraemon.h"
#import "UIImage+Doraemon.h"
@interface DoraemonDemoMultiConScreenEdgePanGesture ()
@property (nonatomic,strong)UIView * edgeView;
@property (nonatomic)CGPoint offsetCenter;
@end
@implementation DoraemonDemoMultiConScreenEdgePanGesture
- (void)viewDidLoad {
[super viewDidLoad];
self.title = DoraemonDemoLocalizedString(@"边缘手势");
UIScreenEdgePanGestureRecognizer * edge = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgePan:)];
edge.edges = UIRectEdgeRight;
[self.view addGestureRecognizer:edge];
}
-(void)edgePan:(UIScreenEdgePanGestureRecognizer *)sender{
if (sender.state == UIGestureRecognizerStateBegan) {
self.edgeView = [[UIView alloc] initWithFrame:CGRectOffset(self.view.frame,CGRectGetWidth(self.view.frame),0)];
self.edgeView.backgroundColor = [UIColor blueColor];
self.offsetCenter = self.edgeView.center;
[self.view addSubview:self.edgeView];
}else if(sender.state == UIGestureRecognizerStateChanged){
CGPoint translation = [sender translationInView:self.view];
self.edgeView.center = CGPointMake(self.offsetCenter.x + translation.x,self.offsetCenter.y);
}else if(sender.state == UIGestureRecognizerStateEnded)
{
if ([sender velocityInView:self.view].x < 0) {
[UIView animateWithDuration:0.3 animations:^{
self.edgeView.center = self.view.center;
}];
}else{
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
self.edgeView.center = self.offsetCenter;
}
completion:^(BOOL finished) {
[self.edgeView removeFromSuperview];
self.edgeView = nil;
}];
}
}else{
[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
self.edgeView.center = self.offsetCenter;
}
completion:^(BOOL finished) {
[self.edgeView removeFromSuperview];
self.edgeView = nil;
}];
}
}
//- (UIImageView *)imageview {
// if(!_imageview){
// CGFloat size = 240;
// _imageview = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.doraemon_width - size) / 2.0, size, self.view.doraemon_width, size)];// CGFloat size =
//
// _imageview.image = [UIImage doraemon_xcassetImageNamed:@"doraemon_file_sync_banner"];
// }
// return _imageview;
//}
@end
//
// DoraemonDemoMultiConSwipeGesture.h
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoBaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface DoraemonDemoMultiConSwipeGesture : DoraemonDemoBaseViewController
@end
NS_ASSUME_NONNULL_END
//
// DoraemonDemoMultiConSwipeGesture.m
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoMultiConSwipeGesture.h"
#import "UIView+Doraemon.h"
#import "UIImage+Doraemon.h"
#import "UIColor+Doraemon.h"
@interface DoraemonDemoMultiConSwipeGesture ()
@property (nonatomic, strong)UIImageView *image3;
@property (nonatomic, strong)UIImageView *image2;
@property (nonatomic, strong)UILabel *label;
@end
@implementation DoraemonDemoMultiConSwipeGesture
- (void)viewDidLoad {
[super viewDidLoad];
self.title = DoraemonDemoLocalizedString(@"滑动手势");
UISwipeGestureRecognizer * swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
swipe.numberOfTouchesRequired = 2;
[swipe setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.view addGestureRecognizer:swipe];
[self.view addSubview:self.image2];
[self.view addSubview:self.image3];
[self.view addSubview:self.label];
self.label.text = @"向左滑方向";
self.label.center = self.view.center;
self.image2.userInteractionEnabled = YES;
self.image2.hidden = NO;
self.image3.userInteractionEnabled = YES;
self.image3.hidden = YES;
}
-(void)swipe:(UISwipeGestureRecognizer *)sender{
if (sender.state == UIGestureRecognizerStateRecognized) {
[UIView transitionWithView:self.view
duration:0.8
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
self.image3.hidden = !self.image3.hidden;
self.image2.hidden = !self.image2.hidden;
} completion:^(BOOL finished) {
}];
}
}
- (UILabel *)label {
if(!_label){
_label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 40)];
_label.textColor = [UIColor doraemon_colorWithString:@"#333333"];
_label.font = [UIFont boldSystemFontOfSize:20];
_label.textAlignment = NSTextAlignmentCenter;
}
return _label;
}
- (UIImageView *)image3 {
if(!_image3){
CGFloat size = 40;
_image3 = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.doraemon_width - 3*size) / 2.0, size*3, size, size)];// CGFloat size =
_image3.image = [UIImage doraemon_xcassetImageNamed:@"doraemon_file_sync"];
}
return _image3;
}
- (UIImageView *)image2 {
if(!_image2){
CGFloat size = 40;
_image2 = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.doraemon_width - 3*size) / 2.0, size*5, size, size)];// CGFloat size =
_image2.image = [UIImage doraemon_xcassetImageNamed:@"doraemon_file_sync"];
}
return _image2;
}
@end
//
// DoraemonDemoMultiConTapGesture.h
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoBaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface DoraemonDemoMultiConTapGesture : DoraemonDemoBaseViewController
@end
NS_ASSUME_NONNULL_END
//
// DoraemonDemoMultiConTapGesture.m
// DoraemonKitDemo
//
// Created by wzp on 2021/7/21.
// Copyright © 2021 yixiang. All rights reserved.
//
#import "DoraemonDemoMultiConTapGesture.h"
#import "UIView+Doraemon.h"
#import "UIImage+Doraemon.h"
@interface DoraemonDemoMultiConTapGesture ()
@property (nonatomic, strong)UIImageView *imageview;
@end
@implementation DoraemonDemoMultiConTapGesture
- (void)viewDidLoad {
[super viewDidLoad];
self.title = DoraemonDemoLocalizedString(@"点击手势");
[self.view addSubview:self.imageview];
self.imageview.userInteractionEnabled = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[self.imageview addGestureRecognizer:tap];
}
- (UIImageView *)imageview {
if(!_imageview){
CGFloat size = 240;
_imageview = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.doraemon_width - size) / 2.0, size, self.view.doraemon_width, size)];// CGFloat size =
_imageview.image = [UIImage doraemon_xcassetImageNamed:@"doraemon_file_sync_banner"];
}
return _imageview;
}
- (void)tap:(UITapGestureRecognizer *)sender {
CAKeyframeAnimation * animation = [CAKeyframeAnimation animation];
animation.keyPath = @"position.x";
NSInteger initalPositionX = self.imageview.layer.position.x;
animation.values = @[@(initalPositionX),
@(initalPositionX + 10),
@(initalPositionX - 10),
@(initalPositionX + 10),
@(initalPositionX)];
animation.keyTimes = @[
@(0),
@(1/6.0),
@(3/6.0),
@(5/6.0),
@(1)];
animation.removedOnCompletion = YES;
[self.imageview.layer addAnimation:animation forKey:@"keyFrame"];
}
@end
......@@ -10,8 +10,14 @@
#import <DoraemonKit/UIView+Doraemon.h>
#import "DoraemonDefine.h"
#import "DoraemonHealthAlertView.h"
#import "DoraemonDemoMultiConLongPressGesture.h"
#import "DoraemonDemoMultiConPinchGesture.h"
#import "DoraemonDemoMultiConRotationGesture.h"
#import "DoraemonDemoMultiConSwipeGesture.h"
#import "DoraemonDemoMultiConTapGesture.h"
#import "DoraemonDemoMultiConScreenEdgePanGesture.h"
@interface DoraemonDemoMultiControlViewController ()
@property (nonatomic,strong) UIScrollView * superScrollView;
@end
@implementation DoraemonDemoMultiControlViewController
......@@ -20,11 +26,15 @@
[super viewDidLoad];
self.title = DoraemonDemoLocalizedString(@"一机多控Demo");
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, IPHONE_NAVIGATIONBAR_HEIGHT, self.view.doraemon_width, 60)];
self.superScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
self.superScrollView.contentSize = CGSizeMake(self.view.doraemon_width, self.view.doraemon_height*1.2);
[self.view addSubview:self.superScrollView];
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.view.doraemon_width, 60)];
btn.backgroundColor = [UIColor orangeColor];
[btn setTitle:DoraemonDemoLocalizedString(@"UIControl 点击事件 系统 AlertView") forState:UIControlStateNormal];
[btn addTarget:self action:@selector(controlEvent) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
[self.superScrollView addSubview:btn];
......@@ -33,18 +43,106 @@
btn_2.backgroundColor = [UIColor orangeColor];
[btn_2 setTitle:DoraemonDemoLocalizedString(@"UIControl 点击事件 系统 UIAlertController") forState:UIControlStateNormal];
[btn_2 addTarget:self action:@selector(controlEvent2) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn_2];
[self.superScrollView addSubview:btn_2];
UIButton *btn_3 = [[UIButton alloc] initWithFrame:CGRectMake(0, btn_2.doraemon_bottom+20, self.view.doraemon_width, 60)];
btn_3.backgroundColor = [UIColor orangeColor];
[btn_3 setTitle:DoraemonDemoLocalizedString(@"UIControl 点击事件 自定义Alertview") forState:UIControlStateNormal];
[btn_3 addTarget:self action:@selector(controlEvent3) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn_3];
[self.superScrollView addSubview:btn_3];
//输入文本
UITextField *field_1 = [[UITextField alloc] initWithFrame:CGRectMake(60, btn_3.doraemon_bottom+20, self.view.doraemon_width-120, 60)];
field_1.placeholder = @"输入文案测试";
field_1.clearButtonMode = UITextFieldViewModeAlways;
field_1.backgroundColor = [UIColor whiteColor];
[self.superScrollView addSubview:field_1];
//输入 UITextView 文本
UITextView *textView_1 = [[UITextView alloc]initWithFrame:CGRectMake(60, field_1.doraemon_bottom+20, self.view.doraemon_width-120, 60)];
textView_1.layer.borderWidth = 0.5;
textView_1.layer.borderColor = [[UIColor lightGrayColor] CGColor];
textView_1.backgroundColor = [UIColor whiteColor];
[self.superScrollView addSubview:textView_1];
// 单击 UITapGestureRecognizer
//左右滑动 UISwipeGestureRecognizer
//旋转 UISwipeGestureRecognizer
//长按
UIButton *longPress = [[UIButton alloc] initWithFrame:CGRectMake(0, textView_1.doraemon_bottom+20, self.view.doraemon_width, 60)];
longPress.backgroundColor = [UIColor orangeColor];
[longPress setTitle:DoraemonDemoLocalizedString(@"长安点击事件") forState:UIControlStateNormal];
[longPress addTarget:self action:@selector(longPressEvent) forControlEvents:UIControlEventTouchUpInside];
[self.superScrollView addSubview:longPress];
//捏合 UIPinchGestureRecognizer
UIButton *pinch = [[UIButton alloc] initWithFrame:CGRectMake(0, longPress.doraemon_bottom+20, self.view.doraemon_width, 60)];
pinch.backgroundColor = [UIColor orangeColor];
[pinch setTitle:DoraemonDemoLocalizedString(@"拟合事件") forState:UIControlStateNormal];
[pinch addTarget:self action:@selector(pinchEvent) forControlEvents:UIControlEventTouchUpInside];
[self.superScrollView addSubview:pinch];
//旋转事件
UIButton *rotation = [[UIButton alloc] initWithFrame:CGRectMake(0, pinch.doraemon_bottom+20, self.view.doraemon_width, 60)];
rotation.backgroundColor = [UIColor orangeColor];
[rotation setTitle:DoraemonDemoLocalizedString(@"旋转事件") forState:UIControlStateNormal];
[rotation addTarget:self action:@selector(rotationEvent) forControlEvents:UIControlEventTouchUpInside];
[self.superScrollView addSubview:rotation];
// 单击 UITapGestureRecognizer
UIButton *tap = [[UIButton alloc] initWithFrame:CGRectMake(0, rotation.doraemon_bottom+20, self.view.doraemon_width, 60)];
tap.backgroundColor = [UIColor orangeColor];
[tap setTitle:DoraemonDemoLocalizedString(@"单击事件") forState:UIControlStateNormal];
[tap addTarget:self action:@selector(tapEvent) forControlEvents:UIControlEventTouchUpInside];
[self.superScrollView addSubview:tap];
//滑动手势 UISwipeGestureRecognizer
UIButton *swipe = [[UIButton alloc] initWithFrame:CGRectMake(0, tap.doraemon_bottom+20, self.view.doraemon_width, 60)];
swipe.backgroundColor = [UIColor orangeColor];
[swipe setTitle:DoraemonDemoLocalizedString(@"滑动手势事件") forState:UIControlStateNormal];
[swipe addTarget:self action:@selector(swipeEvent) forControlEvents:UIControlEventTouchUpInside];
[self.superScrollView addSubview:swipe];
//边缘手势 UIScreenEdgePanGestureRecognizer
UIButton *screenEdgePan = [[UIButton alloc] initWithFrame:CGRectMake(0, swipe.doraemon_bottom+20, self.view.doraemon_width, 60)];
screenEdgePan.backgroundColor = [UIColor orangeColor];
[screenEdgePan setTitle:DoraemonDemoLocalizedString(@"边缘手势事件") forState:UIControlStateNormal];
[screenEdgePan addTarget:self action:@selector(screenEdgePanEvent) forControlEvents:UIControlEventTouchUpInside];
[self.superScrollView addSubview:screenEdgePan];
// 无法识别的手势, 通过touchesBegan 方法来识别
}
- (void)controlEvent{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"点击事件测试" message:@"我是普通警告框"
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"点击事件测试" message:@"我是普通警告框"
delegate:nil cancelButtonTitle:@"好的" otherButtonTitles: nil];
[alert show];
......@@ -77,4 +175,35 @@
[self.navigationController presentViewController:alertController animated:YES completion:nil];
}
- (void)longPressEvent{
DoraemonDemoMultiConLongPressGesture *longPress = [[DoraemonDemoMultiConLongPressGesture alloc]init];
[self.navigationController pushViewController:longPress animated:YES];
}
- (void)pinchEvent {
DoraemonDemoMultiConPinchGesture *pinch = [[DoraemonDemoMultiConPinchGesture alloc]init];
[self.navigationController pushViewController:pinch animated:YES];
}
- (void)rotationEvent {
DoraemonDemoMultiConRotationGesture *rotation = [[DoraemonDemoMultiConRotationGesture alloc]init];
[self.navigationController pushViewController:rotation animated:YES];
}
-(void)tapEvent {
DoraemonDemoMultiConTapGesture *tap = [[DoraemonDemoMultiConTapGesture alloc]init];
[self.navigationController pushViewController:tap animated:YES];
}
-(void)swipeEvent {
DoraemonDemoMultiConSwipeGesture *swipe = [[DoraemonDemoMultiConSwipeGesture alloc]init];
[self.navigationController pushViewController:swipe animated:YES];
}
-(void)screenEdgePanEvent {
DoraemonDemoMultiConScreenEdgePanGesture *screenEdgePan = [[DoraemonDemoMultiConScreenEdgePanGesture alloc]init];
[self.navigationController pushViewController:screenEdgePan animated:YES];
}
@end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册