Xcode 11 beta 4 - 不推荐使用relativeWidth [英] Xcode 11 beta 4 - relativeWidth is deprecated
问题描述
我有一个 VStack
嵌套在 HStack
内,我想占据安全区域宽度的 35%.到目前为止,通过 beta 3,我已经能够做到:
I have a VStack
nested inside of an HStack
that I want to take up 35% of the safe area width. So far through beta 3 I've been able to do the by:
HStack {
VStack {
.
.
.
}.relativeWidth(0.70)
}
但我现在有一个警告:
'relativeWidth' 已弃用
'relativeWidth' is deprecated
就是这样.没有关于使用什么作为替代品.事实上,文档尚未将其标记为已弃用.
That's it. Nothing about what to use as a replacement. In fact, the documentation hasn't yet marked it as deprecated.
关于我可以使用什么作为替代方案的任何想法?GeometryReader
?似乎这太过分了.(我知道,relativeWidth
仍然有效,但我更愿意尽可能删除所有警告.)
Any ideas on what I can use as an alternative? GeometryReader
? It seems that that is overkill. (I know, relativeWidth
still works, but I prefer removing all warnings if possible.)
推荐答案
是的,它已被弃用.发行说明说:
Yes, it is deprecated. The release notes say:
relativeWidth(:)、relativeHeight(:) 和不推荐使用relativeSize(width:height:) 修饰符.使用其他修饰符如框架(最小宽度:理想宽度:最大宽度:最小高度:理想高度:最大高度:对齐:)反而.(51494692).
The relativeWidth(:), relativeHeight(:), and relativeSize(width:height:) modifiers are deprecated. Use other modifiers like frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:) instead. (51494692).
你唯一的选择似乎是 GeometryReader :-(
Your only alternative seems to be GeometryReader :-(
这篇关于Xcode 11 beta 4 - 不推荐使用relativeWidth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!