源码简介
实现可视化的各种手势操作,也就是给手势操作添加轨迹效果,包括点击、滑动、长按等等。
源码运行截图
代码片段
- _- (COSTouchVisualizerWindow *)window
- {
- static COSTouchVisualizerWindow *customWindow = nil;
- if (!customWindow) {
- customWindow = [[COSTouchVisualizerWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- [customWindow setFillColor:[UIColor yellowColor]];
- [customWindow setStrokeColor:[UIColor purpleColor]];
- [customWindow setTouchAlpha:0.4];
- [customWindow setRippleFillColor:[UIColor yellowColor]];
- [customWindow setRippleStrokeColor:[UIColor purpleColor]];
- [customWindow setRippleAlpha:0.1];
- }
- return customWindow;
- }
- - (void)COSTouchVisualizerWindow_commonInit {
- self.strokeColor = [UIColor blackColor];
- self.fillColor = [UIColor whiteColor];
- self.rippleStrokeColor = [UIColor whiteColor];
- self.rippleFillColor = [UIColor blueColor];
- self.touchAlpha = 0.5;
- self.fadeDuration = 0.3;
- self.rippleAlpha = 0.2;
- self.rippleFadeDuration = 0.2;
- self.stationaryMorphEnabled = YES;
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(screenConnect:)
- name:UIScreenDidConnectNotification
- object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(screenDisconnect:)
- name:UIScreenDidDisconnectNotification
- object:nil];
- // Set up active now, in case the screen was present before the window was created (or application launched).
- [self updateFingertipsAreActive];
- }