Created
October 25, 2015 22:38
-
-
Save MoathOthman/b0b8afb51248aad364b6 to your computer and use it in GitHub Desktop.
Find x point and y point of a UIView related to the main screen in swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Find the Y point of a view related to the main screen | |
@pramater UIView the view to start | |
@return CGFloat the y point to the main screen | |
*/ | |
func findOutTheYPointToTheScreen(view: UIView) -> CGFloat { | |
var ypointSummation: CGFloat = view.frame.origin.y | |
var tView = view | |
while let v = tView.superview { | |
ypointSummation += v.frame.origin.y | |
tView = tView.superview! | |
} | |
return ypointSummation | |
} | |
/** Find the Y point of a view related to the main screen | |
@pramater UIView the view to start | |
@return CGFloat the y point to the main screen | |
*/ | |
func findOutTheXPointToTheScreen(view: UIView) -> CGFloat { | |
var ypointSummation: CGFloat = view.frame.origin.x | |
var tView = view | |
while let v = tView.superview { | |
ypointSummation += v.frame.origin.x | |
tView = tView.superview! | |
} | |
return ypointSummation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment