Center UIActivityIndicatorView in a UIImageView Center UIActivityIndicatorView in a UIImageView xcode xcode

Center UIActivityIndicatorView in a UIImageView


center property is view's coordinates in coordinate space of its superview. So you need to set coordinates of your indicator in the coordinate space of imageView. Correct way will be:

indicator.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));


indicator.center = [self convertPoint:self.center fromView:[self superview]];

You only need to convert point because of this (UIView Class Reference):

@property(nonatomic) CGPoint center Discussion

The center is specified within the coordinate system of its superview and is measured in points.