1
我試圖讓UIView
調用object
來旋轉指向另一個UIView
的中心,調用orig
。我似乎無法正確計算角度。我的觸發有點生疏,所以我無法弄清楚我的數學錯誤。旋轉UIView指向另一個UIView
let y0 = object.center.y
let y1 = orig?.center.y
let x0 = object.center.x
let x1 = orig?.center.x
let angle = atan2((y1! - y0), (x1! - x0)) * 180/CGFloat.pi
rotateTo(object: object, degrees: angle, time: deplexed[1] as! CGFloat)