Skip to content

Instantly share code, notes, and snippets.

@chrisvoss
Created August 21, 2012 15:34
Show Gist options
  • Save chrisvoss/3416639 to your computer and use it in GitHub Desktop.
Save chrisvoss/3416639 to your computer and use it in GitHub Desktop.
Style PFLoadingView in PFQueryTableViewController subclass
- (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;
}
}
}
}
}
@Ricardo1980
Copy link

It seems that's what I'm looking for. Can you tell where I have to call stylePFLoadingViewTheHardWay method?
Thanks in advance.

@lborgav
Copy link

lborgav commented Aug 17, 2015

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