Get the current angle/rotation/radian for a UIView?

前端 未结 6 1309
傲寒
傲寒 2021-01-30 12:40

How do you get the current angle/rotation/radian a UIView has?

6条回答
  •  遥遥无期
    2021-01-30 13:28

    Swift:

    // Note the type reference as Swift is now string Strict
    
    let radians:Double = atan2( Double(yourView.transform.b), Double(yourView.transform.a))
    let degrees:CGFloat = radians * (CGFloat(180) / CGFloat(M_PI) )
    

提交回复
热议问题