There's a couple of problems with your code:
-
Assuming that self
is a View Controller, you're only looking at its view
property's subviews, and not its entire hierarchy. So for example, if view
contained a Stack View of buttons, those buttons would be missed. You'd need to write a recursive function instead.
-
if views == UIButton
is not the correct way to check if a view is a button. You'd probably want to instead downcast it as such: if let button = subview as? UIButton
In your question you ask about to iterate all views in the running app. If the code above was correct, it would only iterate the buttons in whatever self
is, which I presume is a single view controller and not the entire app.
However, there is a way to customize appearances in the entire app, using UIAppearance
proxies. But this is only for properties that are marked with UI_APPEARANCE_SELECTOR
. In the case of UIButton
, that includes properties like titleColor
and backgroundImage
, not isPointerInteractionEnabled
.