Determine if UIView is visible to the user?

前端 未结 12 1756
不知归路
不知归路 2020-12-07 15:21

is it possible to determine whether my UIView is visible to the user or not?

My View is added as subview several times into a Tab Bar

12条回答
  •  囚心锁ツ
    2020-12-07 15:51

    You can check if:

    • it is hidden, by checking view.hidden
    • it is in the view hierarchy, by checking view.superview != nil
    • you can check the bounds of a view to see if it is on screen

    The only other thing I can think of is if your view is buried behind others and can't be seen for that reason. You may have to go through all the views that come after to see if they obscure your view.

提交回复
热议问题