Actual screen coordinates of anchor layout constraint linked to a UIView in iOS?

304 views Asked by At

I’m a novice working with an app that lets me bridge Lua to some objective C commands. Using that bridge, I’ve created some controls (e.g, a basic browser WKWebview) using the auto layout in iOS but now want to align some even simpler display items that I’ve created with the app’s Lua commands. Yet, my WKWebview positions are setup on the screen using layout constraints (e.g. Webview.bottomAnchor) while my simpler display items use simple x,y coordinates.

Is there a way that I can obtain the actual screen coordinates of my objective C Webview so that I can align my simpler display items to them (e.g. simpler display model below Webview: simpler display model position.x = Webview.anchorLeft; simpler display model position.y = Webview.anchorBottom)?

Thanks!

1

There are 1 answers

1
SugarRay On

Thanks, DonMag, your clue about the viewDidLayoutSubviews helped me figure out the answer. From searching further online, I saw that I can get the actual coordinates of any UIView by getting extended properties on any UIView I made even if I aligned the view with an auto layout by scripting (in the example I proposed of aligning my simple Lua control under an objective C braided autolayout WebView UIView)

mySimpleControlPositionX = webView.frame.origin.x

mySimpleControlPositionY = (webView.frame.origin.y + webView.frame.size.height)

The stackoverflow.com answer that explains that I found that explained these extended properties of a UIView was at:

Cocoa: What's the difference between the frame and the bounds?

Thank you very much!