Getting the visible rect of an UIScrollView's content

前端 未结 8 488
故里飘歌
故里飘歌 2020-11-30 19:17

How can I go about finding out the rect (CGRect) of the content of a displayed view that is actually visible on screen.

myScrollView.bounds

8条回答
  •  一向
    一向 (楼主)
    2020-11-30 19:22

    Swift 4.0:

    My answer adapts Trenskow's answer to Swift 4.0:

    let visible = scrollView.convert(scrollView.bounds, to: subView)
    

    where scrollView is the view of the scroll, and subView is the view inside scrollView which is zoomable and contains all the contents inside the scroll.

提交回复
热议问题