Created
August 21, 2012 15:34
-
-
Save chrisvoss/3416639 to your computer and use it in GitHub Desktop.
Style PFLoadingView in PFQueryTableViewController subclass
This file contains hidden or 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
- (void)stylePFLoadingViewTheHardWay | |
{ | |
UIColor *labelTextColor = [UIColor whiteColor]; | |
UIColor *labelShadowColor = [UIColor darkGrayColor]; | |
UIActivityIndicatorViewStyle activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite; | |
// go through all of the subviews until you find a PFLoadingView subclass | |
for (UIView *subview in self.view.subviews) | |
{ | |
if ([subview class] == NSClassFromString(@"PFLoadingView")) | |
{ | |
// find the loading label and loading activity indicator inside the PFLoadingView subviews | |
for (UIView *loadingViewSubview in subview.subviews) { | |
if ([loadingViewSubview isKindOfClass:[UILabel class]]) | |
{ | |
UILabel *label = (UILabel *)loadingViewSubview; | |
{ | |
label.textColor = labelTextColor; | |
label.shadowColor = labelShadowColor; | |
} | |
} | |
if ([loadingViewSubview isKindOfClass:[UIActivityIndicatorView class]]) | |
{ | |
UIActivityIndicatorView *activityIndicatorView = (UIActivityIndicatorView *)loadingViewSubview; | |
activityIndicatorView.activityIndicatorViewStyle = activityIndicatorViewStyle; | |
} | |
} | |
} | |
} | |
} |
The same function in Swift is something like this:
func stylePFLoadingViewTheHardWay() {
let labelTextColor = UIColor.whiteColor()
let labelShadowColor = UIColor.blackColor()
let activityIndicatorViewStyle = UIActivityIndicatorViewStyle.White
// go through all of the subviews until you find a PFLoadingView subclass
for view in self.view.subviews {
if NSStringFromClass(view.classForCoder) == "PFLoadingView" {
// find the loading label and loading activity indicator inside the PFLoadingView subviews
for loadingViewSubview in view.subviews {
if loadingViewSubview is UILabel {
var label:UILabel = loadingViewSubview as! UILabel
label.textColor = labelTextColor
label.shadowColor = labelShadowColor
}
if loadingViewSubview is UIActivityIndicatorView {
var indicator:UIActivityIndicatorView = loadingViewSubview as! UIActivityIndicatorView
indicator.activityIndicatorViewStyle = activityIndicatorViewStyle
}
}
}
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems that's what I'm looking for. Can you tell where I have to call stylePFLoadingViewTheHardWay method?
Thanks in advance.