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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With