gpt4 book ai didi

ios - 在 SwiftUI 中,frame(...) 等资格中的数字的单位是什么?

转载 作者:行者123 更新时间:2023-12-01 16:20:31 25 4
gpt4 key购买 nike

例如:

 Text("Hello")
.frame(width: 100, height: 60)
.font(Font.custom("Times New", size: 36.0))

100和60的单位是什么?如果它们的意思是 100 和 60 点,那么该设备如何独立?如果不是积分,它们是什么?

我正在尝试学习如何将项目(如文本或按钮)放置在 View 中的小数位置。例如,如何将项目从顶部向下居中到 View 高度的 40%。我的第一个想法是它们可能是包含 View 的一部分,但这似乎是错误的。

最佳答案

points ,Apple 在自动生成的 SwiftUI API 模块文档的许多地方都提到了这一点,如下面的 .frame 快照所示修饰符描述(请参阅,椭圆将是 200x100 点。)。 .offset 也有类似的和 .position .

/// For example, the first ellipse in the following code is laid out in a
/// fixed 200 by 100 frame. Since a shape always occupies the space offered
/// to it, the first ellipse will be 200x100 points. The second ellipse is
/// laid out in a frame with only a fixed height, so it occupies that
/// height, and whatever width is offered to its parent.
///
/// VStack {
/// Ellipse()
/// .fill(Color.purple)
/// .frame(width: 200, height: 100),
/// Ellipse()
/// .fill(Color.blue)
/// .frame(height: 100)
/// }

实际上,所有与坐标空间相关的内容都与 UIKit 中的相同。

关于ios - 在 SwiftUI 中,frame(...) 等资格中的数字的单位是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61124576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com