Reputation: 1457
I need to add a simple loading animation on top a my view..and want it to be in the center of screen(visible aria)..can anybody point me to the right direction.? how to get the center of the window so that i can addSubview..?
Upvotes: 17
Views: 29761
Reputation: 3134
If you may want to control the center alignment of axis's separately, consider the below answer.
Center/align along the X axis
yourView.center = CGPointMake(self.view.center.x,self.yourView.center.y);
Center/align along the Y Axis
yourView.center = CGPointMake(self.yourView.center.x, self.view.center.y);
Upvotes: 10
Reputation: 170849
Check center property of UIView. You can set your view center to viewControllers root view for example:
yourView.center = self.view.center;
Upvotes: 48