SwiftUI - Get size of child?

前端 未结 4 1145
死守一世寂寞
死守一世寂寞 2020-12-15 08:32

Is there any way to get the size of a child view in SwiftUI?

I\'m basically looking to do the UIKit equivalent of:



        
4条回答
  •  [愿得一人]
    2020-12-15 09:16

    You can use AnchorPreferences to bubble information about a child view's geometry up to a parent view. See: https://swiftui-lab.com/communicating-with-the-view-tree-part-2/

提交回复
热议问题