I have this code:
let x = (self.view.frame.width / 2)
let y = (self.view.frame.height / 2) - (self.navigationController?.navigationBar.frame.height)!
let activityView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.WhiteLarge)
activityView.frame = CGRect(x: 200, y: 120, width: 200, height: 200)
activityView.center = CGPoint(x: x, y: y)
activityView.color = UIColor.blueColor()
activityView.layer.zPosition = 1000
activityView.startAnimating()
activityView.hidesWhenStopped = false
activityView.hidden = false
self.view.addSubview(activityView)
self.view.bringSubviewToFront(activityView)
to create and add an indicator view to my app, but it just doesn't show on the screen.
There is a (long) JSON request in between this and the stopAnimating() call.
This is on top of a video preview layer, which is why I've tried to change the z index and the bringSubviewToFront()
, but it still doesn't show.
Here's what I get when debugging the view hierarchy:
The indicator view is showing there, so it must be being added to the main view. (the blue rectangle is also a separate UIView.)
Here's what I see on the app (no indicator view visible!):
How can I fix this?