iOS coordinate location translation

Source: Internet
Author: User

iOS common coordinates conversion to handle some drop-down box formation of the button position, I have the bottom two to do a personal understanding, the shortcomings of a lot of apologies

-(Cgpoint) Convertpoint: (cgpoint) point Toview: (Nullable UIView *) view;

-(Cgpoint) Convertpoint: (cgpoint) point Fromview: (Nullable UIView *) view;

-(CGRect) Convertrect: (cgrect) Rect toview: (Nullable UIView *) view;

-(CGRect) Convertrect: (cgrect) Rect fromview: (Nullable UIView *) view;

/*

Converts the frame of the current view to the distance from the target view, returning the distance from the real view

RC value = View.fram+rect

*/

View1 is the target view Self.view represents the current view

CGRect rect = CGRectMake (VIEW1.FRAME.SIZE.WIDTH/2, View1.frame.size.height, View1.frame.size.width, View1.frame.size.height);

CGRect rc = [view2 convertrect:rect fromview:view1];

View2.frame =RC;

/*

The distance from the frame of the current view to the target view, returning to the target location

frame = Rect-view.frame

*/

CGRect rect = CGRectMake (n, A, view1.frame.size.width, view1.frame.size.height);

CGRect rc = [view2 convertrect:rect toview:view1];

View2.frame =RC;

NSLog (@ "%@", Nsstringfromcgrect (RC));

iOS coordinate location translation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.