Pet*_*mpf 18
使用iOS8,您可以访问touch.majorRadius属性,该属性CGFloat以10.45的倍数增长,并且以毫米为单位与触摸区域的半径成比例.touch.majorRadiusTolerance是第二个可以与iOS8一起使用的属性,它提供了触摸半径信息的准确性.在我的测量中,它总是一半的majorRadius步长.
在iPad Pro上,触摸屏的灵敏度提高了三倍,并且从Apple铅笔中获取的信号低于旧款iPad型号的报告阈值.铅笔的触摸半径报告为0.25,而即使是最轻微的手指接触也会报告为20.84或更多.
在你的UIView方法中使用它:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// Regular multitouch handling.
[super touchesBegan:touches withEvent:event];
CGPoint center = [touch locationInView:self];
NSLog(@"Touch detected at %6.1f | %6.1f", center.x, center.y);
CGFloat radius = [touch majorRadius];
NSLog(@"Radius = %5.1f; lower limit = %5.1f; upper limit = %5.1f", radius, radius-touch.majorRadiusTolerance, radius+touch.majorRadiusTolerance);
}
Run Code Online (Sandbox Code Playgroud)
大小和压力是两种不同的动物.倒数第二个最有可能测试某个区域的大量触摸(毕竟手掌有很大的面积,产生大量的触摸).
触摸"尺寸"不存在.当手指接触屏幕时会生成IOS触摸事件.操作系统然后从触摸中获取一个中心点,这就是你得到的.它不是CGRect,它是CGPoint.
压力虽然"更容易".请参阅此处获取解决方法:使用加速度计检测压力强度
虽然我发现你在私有API的市场上,github会托管一些类转储:http://github.com/kennytm/iphone-private-frameworks和https://github.com/nst/iOS-运行时,头
如果您对私有感兴趣(即,不要将其提交到app store方法,那么您正在寻找 -
@interface UITouch (Private)
-(float)_pathMajorRadius;
@end
Run Code Online (Sandbox Code Playgroud)
在我(私人!)的使用中,这10是确定一个人何时使用他们的手指/手写笔或将手放在设备上的良好阈值.
希望这对某人有帮助.同样,不要在App Store中使用它.
| 归档时间: |
|
| 查看次数: |
7622 次 |
| 最近记录: |