I created a custom subclass of UIImageView
, and with one method I want to add an activity indicator to the center when the image loads. I am using the following code, but the activity monitor is located outside of UIImageView
. What can I do to center it exactly within a UIImageView
?
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; indicator.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin; indicator.center = self.center; [self addSubview:indicator]; [indicator startAnimating];
source share