ios - 文本标签未根据 ScrollView SwiftUI 中的字符串扩展

标签 ios swift swiftui

enter image description here我只是在 ScrollView 中添加了 TextLabel,但它仅显示在 1 行中。没有 ScrollView ,它在标签的全高下工作正常

 struct UserDetailView: View {

        var userObj:User?

        var body: some View {
            ScrollView {
                VStack {

                    Text("Hi here is Erick jackson. We need to help you. We will help you. Anything new to learn from you. I am here for that reason.")
                        .background(Color.orange)
                        .multilineTextAlignment(.center)
                    .lineLimit(5)
                }
            }
            .padding(.horizontal,30)
        }
    }

最佳答案

Text("Hi here is Erick Jackson....") 之后尝试 .fixedSize 修饰符:

...

Text("Hi here is Erick jackson. We need to help you. We will help you. Anything new to learn from you. I am here for that reason.")
.fixedSize(horizontal: false, vertical: true)

.background(Color.orange)

...

关于ios - 文本标签未根据 ScrollView SwiftUI 中的字符串扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57820928/

相关文章:

php - 适用于 iOS 的 Google 云消息传递 MismatchSenderId

swift - 在表格 View 单元格中键入时键盘会覆盖 TextView

ios - 使用 NSPredicate 的 Swift 过滤器数组

swift - receiveData :fromPeer:inSession:context: in swift? 的正确签名是什么

ios - 如何在 SwiftUI 中的两个观察对象之间传递数据

ios - 在transitionFromViewController中传递数据

ios - Swift - 在点击按钮时添加和删除 UILabel

ios - 使用 SwiftUI 成功登录后导航

SwiftUI 标签 View 修复

ios - 难以捉摸的 UIView 子类名称