根据MacRumor(http://www.macrumors.com/2014/06/17/pencil-stylus-pressure-ios-8/),iOS 8将支持模拟表面压力的可变触摸尺寸。我在哪里可以找到它的API?我搜索了Apple Developer iOS开发中心在线图书馆,但无法找到它。
答案 0 :(得分:5)
iOS 8在UITouch上添加了两个新属性:majorRadius和majorRadiusTolerance。他们的工作方式如下:
override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) {
var touch : UITouch = touches.anyObject() as UITouch
var lowerBound = touch.majorRadius - touch.majorRadiusTolerance
var upperBound = touch.majorRadius + touch.majorRadiusTolerance
var average = (lowerBound + upperBound) / 2.0
println("touch was between \(lowerBound)pt and \(upperBound)pt in size (avg \(average)")
}
您可以找到文档here(需要在预发布时登录)。
答案 1 :(得分:0)
我将签名更改为(没有可选参数符号"!")
override func touchesMoved(touches: NSSet, withEvent event: UIEvent)
因为XCode Beta 1会抛出SpriteKit编译器错误。也许它已在Beta 2中修复。(更新:该bug仍然存在)。