简体   繁体   English

Xcode 11 beta 4 - 不推荐使用relativeWidth

[英]Xcode 11 beta 4 - relativeWidth is deprecated

I have a VStack nested inside of an HStack that I want to take up 35% of the safe area width.我有一个嵌套在VStack内部的HStack ,我想占据安全区域宽度的 35%。 So far through beta 3 I've been able to do the by:到目前为止,通过 beta 3,我已经能够做到:

HStack {
    VStack {
        .
        .
        .
    }.relativeWidth(0.70)
}

But I now have a warning that:但我现在有一个警告:

'relativeWidth' is deprecated 'relativeWidth' 已弃用

That's it.就是这样。 Nothing about what to use as a replacement.没有关于使用什么作为替代品。 In fact, the documentation hasn't yet marked it as deprecated.事实上,文档尚未将其标记为已弃用。

Any ideas on what I can use as an alternative?关于我可以使用什么作为替代方案的任何想法? GeometryReader ? GeometryReader It seems that that is overkill.似乎这太过分了。 (I know, relativeWidth still works, but I prefer removing all warnings if possible.) (我知道, relativeWidth仍然有效,但如果可能,我更喜欢删除所有警告。)

Yes, it is deprecated.是的,它已被弃用。 The release notes say: 发行说明说:

The relativeWidth( :), relativeHeight( :), and relativeSize(width:height:) modifiers are deprecated.不推荐使用 relativeWidth( :)、relativeHeight( :) 和 relativeSize(width:height:) 修饰符。 Use other modifiers like frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:) instead.使用其他修饰符,如 frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:) 代替。 (51494692). (51494692)。

Your only alternative seems to be GeometryReader :-(您唯一的选择似乎是 GeometryReader :-(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM