【问题标题】:Tttach an object to the bottom of the screen将对象附加到屏幕底部
【发布时间】:2021-01-29 00:42:06
【问题描述】:

我遇到了一个问题 - 我无法将文本附加到屏幕底部 - Text("Общи условия и поверителност")- 当屏幕扩大一点时,对象是在底部,但它不会改变它在大屏幕上的位置。我尝试使用 Stack { space() item } 但随后该对象刚刚超出了屏幕的视野。我做错了什么?

附: Text("Общи условия и поверителност")

iphoneSE:

iphone11:

【问题讨论】:

  • SwiftUI 我假设(因为你说Stack { space() item })?还是自动布局/框架?
  • @aheze i menia Stack

标签: ios swift xcode view swiftui


【解决方案1】:

尝试用.position(x: UIScreen.main.bounds.size.height)定位屏幕

您可以使用此扩展来获得更简洁的代码 -

extension UIScreen {
   static let screenWidth = UIScreen.main.bounds.size.width
   static let screenHeight = UIScreen.main.bounds.size.height
   static let screenSize = UIScreen.main.bounds.size
}

如果你想更准确,你可以像这样使用 GeometryReader -

GeometryReader { geo in 
   Text("Общи условия и поверителност")
       .potision(x: UIScreen.screenHeight - geo.safeAreaInsets.top)
}

这还将包括计算中的安全区域

【讨论】:

    【解决方案2】:

    尝试使用 .position(x: UIScreen.main.bounds.size.height)

    您可以使用此扩展来获得更简洁的代码 -

    扩展 UIScreen { static let screenWidth = UIScreen.main.bounds.size.width 静态让 screenHeight = UIScreen.main.bounds.size.height static let screenSize = UIScreen.main.bounds.size } 如果你想更准确,你可以 GeometryReader 像这样 -

    GeometryReader { 文本中的地理(“Общи условия и поверителност”) .potision(x: UIScreen.screenHeight - geo.safeAreaInsets.top) } 这还将包括计算中的安全区域

    @AvivProfesorsky -

    对象已消失,但您仍然可以单击它并转到另一个屏幕 o_O

    【讨论】:

      猜你喜欢
      • 2018-04-03
      • 2015-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多