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
2010-10-25 07:22:12
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
2010-10-25 07:32:14
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
2010-10-25 07:40:24
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
2010-10-25 07:43:00
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
2010-10-25 07:49:08
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
2010-10-25 07:53:49
Thanks Vladimir..it did the the trick.
Aji
2010-10-25 08:05:12
When i rotate the screen its not displaying correctly.do i have to redraw the whole thing again?
Aji
2010-10-25 08:38:58
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
2010-10-25 08:41:50