COSTouchVisualizer 1.0.6

COSTouchVisualizer 1.0.6

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2015年3月

Joe Blau 维护。




COSTouchVisualizer

Swift 使用

使用 Swift 可以使用 COSTouchVisualizer。在您的 AppDelegate 中,重新定义您的窗口并使用 storyboards 声明一个可视化窗口。

使用 Storyboards

class AppDelegate: UIResponder {
  lazy var window: COSTouchVisualizerWindow? = {
    COSTouchVisualizerWindow(frame: UIScreen.mainScreen().bounds)
  }()
...
}

不使用 Storyboards

Objective-C 使用

要运行示例项目;克隆仓库,并首先从 Example 目录运行 pod update。默认情况下,此项目未启用 调试模式。如果您希望在测试时查看手势,请按照 调试模式 说明操作。

使用 Storyboards,在您的 AppDelegate 实现中只需添加以下 getter

#import <COSTouchVisualizerWindow.h>

...

// Add this method to your AppDelegate method
- (COSTouchVisualizerWindow *)window {
    static COSTouchVisualizerWindow *visWindow = nil;
    if (!visWindow) visWindow = [[COSTouchVisualizerWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    return visWindow;
}

不使用 Storyboards

#import <COSTouchVisualizerWindow.h>

...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Setup window
    self.window = [[COSTouchVisualizerWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];

    ...

}

委托

为了使窗口动态更改活动状态或启用调试模式,您可以使一个对象实现 COSTouchVisualizerWindowDelegate 协议。

此委托协议中有 2 个可选方法

- (BOOL)touchVisualizerWindowShouldShowFingertip:(COSTouchVisualizerWindow *)window;
- (BOOL)touchVisualizerWindowShouldAlwaysShowFingertip:(COSTouchVisualizerWindow *)window;

默认情况下,窗口仅在存在镜像窗口时显示指尖。

第一个委托方法(-touchVisualizerWindowShouldShowFingertip:)告诉窗口是否启用指尖。如果需要启用指尖功能,应该返回 YES,如果要关闭此功能,则返回 NO

第二个方法(-touchVisualizerWindowShouldAlwaysShowFingertip:)告诉窗口始终显示指尖,即使没有镜像屏幕(当返回 YES 时)。如果此方法返回 NO,则窗口仅在连接到镜像屏幕时显示指尖。

- (COSTouchVisualizerWindow *)window {
  if (!_customWindow) {
    _customWindow = [[COSTouchVisualizerWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    // ... other setup code

    _customWindow.touchVisualizerWindowDelegate = self;
  }
  return _customWindow;
}

- (BOOL)touchVisualizerWindowShouldAlwaysShowFingertip:(COSTouchVisualizerWindow *)window {
    return YES;  // Return YES to make the fingertip always display even if there's no any mirrored screen.
                 // Return NO or don't implement this method if you want to keep the fingertip display only when
                 // the device is connected to a mirrored screen.
}

- (BOOL)touchVisualizerWindowShouldShowFingertip:(COSTouchVisualizerWindow *)window {
    return YES;  // Return YES or don't implement this method to make this window show fingertip when necessary.
                 // Return NO to make this window not to show fingertip.
}

自定义

// Add these lines after the windows is initialized
// Touch Color
[visWindow setFillColor:[UIColor yellowColor]];
[visWindow setStrokeColor:[UIColor purpleColor]];
[visWindow setTouchAlpha:0.4];
// Ripple Color
[visWindow setRippleFillColor:[UIColor yellowColor]];
[visWindow setRippleStrokeColor:[UIColor purpleColor]];
[visWindow setRippleAlpha:0.1];

要求

此项目需要 ARC。

安装

作者

Joe Blau,[email protected]

许可证

COSTouchVisualizer 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。