How to know the current scale of a UIView?

后端 未结 6 972
一整个雨季
一整个雨季 2020-12-16 12:16

How do you find the current scale (zoom level) of a UIView?

6条回答
  •  春和景丽
    2020-12-16 12:35

    According to this source, using this method gives you the scale regardless of rotation or translation applied to transform:

    func scale(from transform: CGAffineTransform) -> Double {
        return sqrt(Double(transform.a * transform.a + transform.c * transform.c));
    }
    

    I know I am late to the party but the accepted answer didn't work in my case.

提交回复
热议问题