xcode – 在NSScrollView(Swift)中显示文本
发布时间:2020-12-14 18:59:45 所属栏目:百科 来源:网络整理
导读:刚开始学习 Swift并创建了一个小macOS应用程序,我想在其中使用NSScrollView来显示属性String.我试过了: @IBOutlet var ScrollViewOutlet : NSScrollViewvar attributedString = NSMutableAttributedString(string: myText)ScrollViewOutlet.insertText(attr
刚开始学习
Swift并创建了一个小macOS应用程序,我想在其中使用NSScrollView来显示属性String.我试过了:
@IBOutlet var ScrollViewOutlet : NSScrollView var attributedString = NSMutableAttributedString(string: myText) ScrollViewOutlet.insertText(attributedString) 但这似乎不起作用.我发现有点令人困惑,因为与NSTextView完全相同,而不是像魅力. 我在这里错过了什么? 解决方法
在下面的示例中,我在界面构建器中添加了scrollView作为我的起点.
如果您的scrollView / textView为空/空白,或者如果您需要在scrollView / textView中已有的文本前面附加文本,则以下情况有效.如果框中已有文本,则新文本将插入现有文本的前面. documentView是一个NSTextView Swift 4.0 @IBOutlet weak var imageDestinationDirectory: NSScrollView! ... let destinationText = "Text to display" imageDestinationDirectory.documentView!.insertText(destinationText) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |