How to know the current scale of a UIView?

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

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

6条回答
  •  清歌不尽
    2020-12-16 12:34

    That functionality is provided with UIScrollView and it's zoomScale property.

    EDIT:

    Knowing the current scale is given by the transformation matrix. The scale values, as you know, are here:

    sx, 0,  0
    0 , sy, 0
    . . .. ,1. 
    

    To get the current state, just record the transform's state. To return to that state, however, you'll need to use the inverse of your last transformation or load the identity matrix.

提交回复
热议问题