Accessing SubViews in SwiftUI, as seen in UIKit

Is there a way to mimic this functionality found in UIKit in SwiftUI?

Long story short, I am creating an interactive SceneKit view (currently in UIKit) that anchors 2D UIViews over nodes, for navigation and labelling.

I would like to migrate over to SwiftUI, but I am having difficulties mimicking this functionality.

let subViews = self.view.subviews.compactMap{$0 as? UIButton}
if let view = subViews.first(where: {$0.currentTitle == label}) {
   view.center = self.getScreenPoint(renderer: renderer, node: node)
}

Can anyone help me with this?

Thanks!

Post not yet marked as solved Up vote post of dougkilby Down vote post of dougkilby
899 views

Replies

you might try embedding your SwiftUI inside UIKit with UIHostingConfiguration… semi.dev did a nice writeup:

https://hemi.dev/uihostingconfiguration/