nsviewrepresentable

How to auto-expand height of NSTextView in SwiftUI?

落爺英雄遲暮 提交于 2020-08-10 19:11:25
问题 How do I properly implement NSView constraints on the NSTextView below so it interacts with SwiftUI .frame()? Goal An NSTextView that, upon new lines, expands its frame vertically to force a SwiftUI parent view to render again (i.e., expand a background panel that's under the text + push down other content in VStack). The parent view is already wrapped in a ScrollView. Since the SwiftUI TextEditor is ugly and under-featured, I'm guessing several others new to MacOS will wonder how to do the

How to render multiline text in SwiftUI List with correct height?

我怕爱的太早我们不能终老 提交于 2020-05-14 18:42:07
问题 I would like to have a SwiftUI view that shows many lines of text, with the following requirements: Works on both macOS and iOS. Shows a large number of strings (each string is backed by a separate model object). I can do arbitrary styling to the multiline text. Each string of text can be of arbitrary length, possibly spanning multiple lines and paragraphs. The maximum width of each string of text is fixed to the width of the container. Height is variable according to the actual length of