swiftui - lineLimit in View does not work in SwiftUI
问题描述
The text inside my chatbubbles won't break in new line.
Here's the "chatbubble" extracted in an own view
struct chatPartnerBubble: View {
var textMsg: String
var body: some View {
VStack(alignment: .leading) {
HStack {
HStack {
Text(textMsg)
.foregroundColor(Color.white)
.padding(10)
.lineLimit(nil)
}
.background(Color.blue)
.cornerRadius(12)
Spacer()
}.padding(.leading)
}
}
}
and here is the ChatView
ScrollView {
VStack {
chatPartnerBubble(textMsg: "text")
chatPartnerBubble(textMsg: "text")
chatPartnerBubble(textMsg: "text")
chatPartnerBubble(textMsg: "text")
chatPartnerBubble(textMsg: "text")
chatPartnerBubble(textMsg: "text")
}
}
But if the textMsg is longer, it just dots..., and does not break into new line
解决方案
推荐阅读
- python - 针对不在 [0,1] 内的概率调试神经网络 dropout 问题
- azure-devops - 如何在 Scrum 模板下提取 Azure DevOps 中的人员工作量报告?
- indexeddb - 浏览器扩展可以下载现成的 IndexedDB 数据库吗?
- python - 从元组字典中获取最大值
- c++ - 函数范围的静态变量如何导致与共享库中函数代码的未来使用不兼容
- arrays - 找到四倍数
- c# - 使用 c# 在 monogame 的其他类中访问 GraphicsDeviceManager
- r - 在每个记录/行级别在 R 中创建一个计算字段
- wordpress - 按上个月前发布的帖子数获取用户列表
- python-3.x - 无法使用 TensorFlow 旧版本和新版本