Last active
August 29, 2015 14:24
-
-
Save djtech42/f8784bb7268ae6d0bfc1 to your computer and use it in GitHub Desktop.
Process subviews of a specific type recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Perform function on all views that match type specified by function parameter. | |
*/ | |
func iterateThroughViewsIn<SpecificViewType>(view: UIView, function: SpecificViewType -> Void) { | |
for subview in view.subviews { | |
if let viewOfSpecificType = subview as? SpecificViewType { | |
function(viewOfSpecificType) | |
} | |
iterateThroughViewsIn(subview, function: function) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iterateThroughViewsIn(view, function: { (scrollView: UIScrollView) in | |
scrollView.scrollEnabled = false | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment