I need to draw a line across a custom UIView(i.e. from top-left to bottom-right). However, as far as I know, the coordinate systems are different.
How can I translate between those two coordinate systems?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As long as we are talking about UIView objects that are subview of some other UIView object – the quite normal case – each View is positioned in relation to its next super view. The top left corner of the superview is (0,0).
For most applications that simply works fine. In rather rare cases there may be a need to transform coordinates from one views’s sub-view-coordinate-system to that of another view. UIView provides the methods
for that usage. They work quite fine. Before you make use of them you should re-think whether that is required and evaluate whether your current view hierarchy could do with a re-desin. 🙂