'Execute code when UIView has been visible for a specified time

In an iOS app (using UIKit), a specific action should be performed when a UIView has been "seen" by the user for at least 30 seconds.

A generic approach or an extension for UIView would be nice.

What are good indicators that a UIView is visible to the user?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source