I have added spacer(minLength: 5) but it takes the minlenght can I specify the spacing between the text. I have attached a screenshot for reference I want to reduce the spacing between inner hstack.

HStack {
Image("Rhea").resizable().cornerRadius(25).frame(width: 50.0, height: 50.0)
    VStack(alignment: .leading) {
        Text("How to enjoy your life without money").bold().font(.system(size: 20))
        HStack {
            Text("Lets create")
            Spacer(minLength: 5)
            Text("3K views")
            Spacer(minLength: 5)
            Text("3 hours ago")
        }
    }
}

enter image description here

推荐答案

Add a spacing attribute to the HStack itself. For a spacing of e.g. 10:

HStack {
    Image("Rhea").resizable().cornerRadius(25).frame(width: 50.0, height: 50.0)
    VStack(alignment: .leading) {
        Text("How to enjoy your life without money").bold().font(.system(size: 20))
        HStack(spacing: 10) {
            Text("Lets create")
            Text("3K views")
            Text("3 hours ago")
        }
    }
}

Swift相关问答推荐

如何禁用MacOS上SwiftUI中按钮周围的聚焦环(或高亮显示)?

SwiftUI map 旋转

解码器是否需要具有密钥的外部数据表示?

将 Encodable 扩展添加到 Swift 嵌套枚举

一组可散列的自定义元素插入相等的元素

如何自己实现同一个 iOS 16 锁屏圆形小部件?

在主要参与者中启动分离任务和调用非隔离函数之间的区别

try 制作一个 Swift 扩展来替换字符串中的多次出现

使 Picker 与其他 BinaryInteger 类型兼容

Swift Swiftui - 将 colored颜色 保存到 UserDefaults 并从 @AppStorage 使用它

无法增加系统镜像的大小

任何使 ScrollView 像 List 一样执行更灵活的修饰符?

SwiftUI 文本被意外截断

macOS 守护进程应该由Command Line ToolXcode 模板制作吗?

快速的 AES 加密

Swift 4 Decodable - 以枚举为键的字典

在 Swift 中,你可以用另一个字符串分割一个字符串,而不仅仅是一个字符吗?

如何在 SwiftUI 中以编程方式滚动列表?

如何快速格式化用户显示(社交网络等)的时间间隔?

Swift3 中的 NSIndexPath 初始化有何变化?