views:

30

answers:

1

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..?

+2  A: 

Check center property of UIView. You can set your view center to viewControllers root view for example:

yourView.center = self.view.center;
Vladimir
loadingView.center = aSuperview.center;loadingView.frame.size = CGSizeMake(300, 300);//when setting this Xcode throws an error Lvalue required as aleft operand assignment..im stuck at this..
Aji
oh that was my fault..i need to set the frame as whole like this.CGRect newFrame = loadingView.frame ; newFrame.size.height = 300; newFrame.size.width = 300; loadingView.frame = newFrame; Thanks Vladimir
Aji
loadingView.frame.size returns a CGRect, which is not a l-value. To set frame size you either need to use separate variable (CGRect newFrame = loadingView.frame; newFrame.size = CGSizeMake(); loadingView.frame = newFrame) or explicitly set all frame components: loadingView.frame.size = CGRectMake(0,0, 300, 300);
Vladimir
That x,y positions in your CGRectMake confuses me.if i do like it,will it be on the top left corner of my screen..?how do i make it to center..?
Aji
set the size at first (by setting the frame), and after that move set the view center to the center of the screen - so it will be centered as needed
Vladimir
Thanks Vladimir..it did the the trick.
Aji
When i rotate the screen its not displaying correctly.do i have to redraw the whole thing again?
Aji
I'm not sure, but you really may need to adjust view frames on rotation - that may depend on autoresizing masks set to views
Vladimir