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
The solution that worked for me was to first check if the view has a window, then to iterate over superviews and check if:
Seems to work well so far.
public func isVisible(view: UIView) -> Bool {
if view.window == nil {
return false
}
var currentView: UIView = view
while let superview = currentView.superview {
if (superview.bounds).intersects(currentView.frame) == false {
return false;
}
if currentView.isHidden {
return false
}
currentView = superview
}
return true
}