Reputation: 1336
Goal : How we can find the position of subView in a View. I wants to find out the upper left (x,y)position of my scrollBar in a View, I am also using navigation Bar in my Application does it effect on the positioning of subViews from the Top?
I know how to find the height and width of subview like
CGSize viewSize = scrollView.frame.size;
height=viewSize.height;
width=viewSize.width;
Upvotes: 1
Views: 2631
Reputation: 2253
You can use this one too...
CGRect rect = [scrollBar frame];
float origineFromX = rect.origin.x;
float origineFromY = rect.origin.y;
may this will help you ...
Upvotes: 0
Reputation: 2683
If you put navigation bar in the view, the position of the scrollview has to be shifted downwards to align properly in the view. The origin(top left position) of the scrollview will be different with and without the Navigation bar.
If you are using a fullscreen scrollview, you have to reduce the height of the scrollview to accomodate the navigation bar.
Upvotes: -1
Reputation: 14304
What you're looking for is probably:
CGPoint viewPosition = scrollView.frame.origin;
x=viewPosition.x;
y=viewPosition.y;
But if you're looking to translate to another view's coordinate system, you could use:
- (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view
And pass it the point and view you wish to translate.
Upvotes: 3
Reputation: 21221
To get the x and y use origin
CGPoint point = scrollView.frame.origin;
float x = point.x;
float y = point.y;
Upvotes: 0