Search code examples
iosiphoneobjective-cframesubviews

Calculating The Origin of UIButton Directly from the Self.view in iOS


My objects' hierarchy is as follows,

enter image description here

Let's say the UIButton's object name is 'myButton'.
Now, Is there any way to Calculate the origin(X Coordinate,Y Coordinate) of 'myButton' directly from self.view not by using any intermediate objects' frames?

Any comments or suggestions would be appreciated.

Thank you in advance.


Solution

  • for UIView

    - (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view;
    - (CGPoint)convertPoint:(CGPoint)point fromView:(UIView *)view;
    
    CGPoint pt = [button converPoint:button.bound.origin toView:self.view];