Skip to content

FORGestureTrackDisplay is debug tool to displaying and tracking all kinds of gustures when user touch the screen.

License

Notifications You must be signed in to change notification settings

ZhipingYang/FORGestureTrackDisplay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FORGestureTrackDisplay

FORGestureTrackDisplay is debug tool to displaying and tracking all kinds of gustures when user touch the screen.

untitled

Usage

first method ( Manual )

in this way, just the appdelegate.window can track gustures.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    [self.window startTracking];
    
    return YES;
}

second method ( auto )

I highly recommend this way for auto track gestures in all windows.

@implementation NSObject (Runtime)

+ (void)swizzleInstanceMethodWithOriginSel:(SEL)oriSel swizzledSel:(SEL)swiSel {
    Method originAddObserverMethod = class_getInstanceMethod(self, oriSel);
    Method swizzledAddObserverMethod = class_getInstanceMethod(self, swiSel);
    
    [self swizzleMethodWithOriginSel:oriSel oriMethod:originAddObserverMethod swizzledSel:swiSel swizzledMethod:swizzledAddObserverMethod class:self];
}

+ (void)swizzleMethodWithOriginSel:(SEL)oriSel
                         oriMethod:(Method)oriMethod
                       swizzledSel:(SEL)swizzledSel
                    swizzledMethod:(Method)swizzledMethod
                             class:(Class)cls {
    BOOL didAddMethod = class_addMethod(cls, oriSel, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
    
    if (didAddMethod) {
        class_replaceMethod(cls, swizzledSel, method_getImplementation(oriMethod), method_getTypeEncoding(oriMethod));
    } else {
        method_exchangeImplementations(oriMethod, swizzledMethod);
    }
}
@end
@implementation UIWindow (Runtime)

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        [self swizzleInstanceMethodWithOriginSel:@selector(becomeKeyWindow) swizzledSel:@selector(xy_becomeKeyWindow)];
        [self swizzleInstanceMethodWithOriginSel:@selector(resignKeyWindow) swizzledSel:@selector(xy_resignKeyWindow)];
    });
}

- (void)xy_becomeKeyWindow
{
    [self xy_becomeKeyWindow];
    [self startTracking];
}

- (void)xy_resignKeyWindow
{
    [self xy_resignKeyWindow];
    [self endTracking];
}
@end

Installation

FORGestureTrackDisplay is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "FORGestureTrackDisplay"

Author

XcodeYang, [email protected]

License

FORGestureTrackDisplay is available under the MIT license. See the LICENSE file for more info.

About

FORGestureTrackDisplay is debug tool to displaying and tracking all kinds of gustures when user touch the screen.

Topics

Resources

License

Stars

Watchers

Forks

Packages