开发者

How do you get the absolute x/y position of an embedded element in a UIView?

开发者 https://www.devze.com 2023-03-29 08:32 出处:网络
If you have UIView\'s embeded within other UIView\'s, when you get the .frame.origin.x value of a widget in the internal embedded view, it gives you the x/y value for the position in the internal view

If you have UIView's embeded within other UIView's, when you get the .frame.origin.x value of a widget in the internal embedded view, it gives you the x/y value for the position in the internal view's coordinate system.

I want to get the x/y position of the element in the absolute coordinate system of the entire iPad visible area. (Or with respe开发者_如何学编程ct to the top-most view.)


There are methods which can help you to convert frame.
- (CGRect)convertRect:(CGRect)rect toView:(UIView *)view
- (CGRect)convertRect:(CGRect)rect fromView:(UIView *)view

CGRect f = [someView convertRect:someView.bounds toView:window];
0

精彩评论

暂无评论...
验证码 换一张
取 消