admin管理员组文章数量:1122832
I have the following view - .swift
VStack(alignment: .leading, spacing: 0) {
// some code
Text(item.text)
.controlSize(.regular)
.lineLimit(100)
// more code
}
.frame(maxWidth: 800)
The text wraps finely for multiline content but fails to wrap for single-line strings. Is there any way to properly wrap the text so it spawns on multiple lines?
I've tried multiple combinations of lineLimit, fixedSize, geometry reader, but every solution ended up breaking in some other weird way.
What I am trying to achieve:
What I get instead:
I have the following view - https://github.com/p0deje/Maccy/blob/master/Maccy/Views/PreviewItemView.swift
VStack(alignment: .leading, spacing: 0) {
// some code
Text(item.text)
.controlSize(.regular)
.lineLimit(100)
// more code
}
.frame(maxWidth: 800)
The text wraps finely for multiline content but fails to wrap for single-line strings. Is there any way to properly wrap the text so it spawns on multiple lines?
I've tried multiple combinations of lineLimit, fixedSize, geometry reader, but every solution ended up breaking in some other weird way.
What I am trying to achieve:
What I get instead:
Share Improve this question asked Nov 22, 2024 at 14:23 p0dejep0deje 4,0531 gold badge28 silver badges37 bronze badges 01 Answer
Reset to default 0I guess this is only a preview issue, since preview does not really care with high priority for your frame with the maxWidth parameter.
So you better try
.frame(width: 800)
at the Preview part instead, it will work.
#Preview {
ContentView()
.frame(width: 800)
}
If it happens on the popover when running the app, you should also consider giving it a fixed width.
本文标签: swiftuiHow to wrap a text inside a macOS popoverStack Overflow
版权声明:本文标题:swiftui - How to wrap a text inside a macOS popover - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303177a1931794.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论