我有一个 UIView,它由许多动态子视图组成,包括 UIStackView。
我必须添加这个 UIView 作为我的 tableFooter,所以我需要计算它的高度。我尝试使用以下两种方法计算高度,但尺寸不正确且为零。
//got incorrect size
let targetSize = CGSize(width: 300, height: UIView.layoutFittingCompressedSize.height)
let prefSizs = footerView.systemLayoutSizeFitting(targetSize)
footer.frame = CGRect(x: 0, y: 0, width 300, height: prefSize.height)
//got zero frame
let frame = footerView.frame
我是否可以根据给定的宽度为我的动态 UIView 找到正确的高度?