Coordinate transformation in ios--UIView

Source: Internet
Author: User

Converts pixel point from view to target view, returns the pixel value in the target view

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

Converts a pixel point from view to the current view, returning the pixel value in the current view

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

Converts a rect from the view of a rect to the target view, returning the RECT in the target view

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

Converts a rect from view to the current view, returning a rect in the current view

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

Example converts a frame of subview (BTN) in UITableViewCell to Controllera

There is a uitableview in the Controllera, there is a button on Uitableviecell,cell in UITableView.

Implemented in Controllera:

CGRect rc = [cell convertRect:cell.btn.frame ToView:self.view];


CGRect rc = [Self.view convertRect:cell.btn.frame Fromview:cell];

This RC is a rect of btn in Controllera

Or when known btn:

CGRect rc = [Btn.superview convertRect:btn.frame ToView:self.view];


CGRect rc = [Self.view convertRect:btn.frame FromView:btn.superview];

Coordinate transformation in ios--UIView

Related Article

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: 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.