Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing activity indicator color to black

I'm trying to change my activity indicator to a custom color like black. However it does not seem to apply at all and has the standard white color still.

What i've done is creating a UIView and and added a activity indicator as a subView and then added this to the tableFooterView.

How can I change the activity indicator color?

ViewDidLoad:

    let footerView = UIView(frame: CGRectMake(0, 0, self.view.frame.size.width, 40))     footerView.backgroundColor = UIColor(rgba: "#f6f7f9")     var actInd: UIActivityIndicatorView = UIActivityIndicatorView()     actInd.color = UIColor.blackColor()     actInd.frame = CGRectMake(self.view.frame.size.width/2-10, 0.0, 20.0, 20.0);      actInd.activityIndicatorViewStyle =         UIActivityIndicatorViewStyle.WhiteLarge     footerView.addSubview(actInd)     actInd.startAnimating()     self.tableVIew.tableFooterView = footerView 
like image 888
Peter Pik Avatar asked Apr 17 '15 11:04

Peter Pik


1 Answers

You need to set the color after you set the activity indicator style. It seems that setting the activityIndicatorViewStyle resets the color for the activityIndicator

So just do this:

// ....   activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.whiteLarge activityIndicator.color = .black footerView.addSubview(activityIndicator) activityIndicator.startAnimating() self.tableView.tableFooterView = footerView 

This should work just fine.

like image 59
Catalina T. Avatar answered Sep 19 '22 16:09

Catalina T.