我弄清楚了,我不得不使用确定屏幕宽度的数学函数组合,我必须从那里完善一些数字。
以下是有效方法的一般概念:
override func touchesMoved(_ touches: Set<UITouch>,with event: UIEvent?) {
if let touch = touches.first {
let location = touch.location(in: timeCircle)
let extraGrip: CGFloat = -25.0
if let last = lastLocation,location.x > extraGrip,location.y > extraGrip {
let rad = radiansBetweenPoint(location,last)
let value = (CGFloat(rad)/CGFloat.pi)*180
let currentAngle: CGFloat = ((radiansBetweenPoint(lineCenter,linePoint!)/CGFloat.pi)*180.0)-90.0
let newValue = value+currentAngle+180.0
var index: CGFloat = (newValue/360.0)*12
if roundf(Float(index)) <= 0 {
index += 12
}
//skip 2 o clock
if roundf(Float(index)) == 2 {
index += 1
}
setLineToPoint(pointForArcByIndex(index: index))
setTimeFromIndex(index)
lastIndex = index
}
}
}
本文链接:https://www.f2er.com/3091829.html