Can't manipulate subview properties after it has been added to superview - iOS Swift

67 views Asked by At

I'm trying to add a UIActivityIndicatorView to a button. The problem is, once the activity indicator view is added as a subview, I can no longer do anything with it. Here's my code below:

saveAiv = UIActivityIndicatorView(frame: CGRect(x: 10, y: 10, width: 20, height: 20))
saveAiv.color = .white
saveAiv.startAnimating()
saveAiv.isHidden = false
startQuizButton.addSubview(saveAiv)
self.view.addSubview(startQuizButton)

If I call startAnimating() and set isHidden before the subview is added, it works, but if I try to do anything with the activity view after it's added it has no effect. What is going on here?

0

There are 0 answers