来自 NSAttributedString 的 Xamarin NSTextStorage

Hei*_*erg 2 xamarin.ios xamarin

我试图将此行移植到 xamarin

let textStorage = NSTextStorage(attributedString: self.attributedText!)
Run Code Online (Sandbox Code Playgroud)

但我找不到采用 NSAttributedString 的构造函数或静态方法。

Sus*_*ver 5

NSTextStorageattributedString:初始值设定项在 上丢失Xamarin.iOS

您可以执行Append| Insert在您的NSTextStorage对象上(实际上是在NSMutableAttributedString子类上附加/插入)。

由于您的 NSTextStorage 在刚刚实例化时将为空,因此只需使用Append

var textStorage = new NSTextStorage();
textStorage.Append(someMutableAttributedString);
Run Code Online (Sandbox Code Playgroud)

注意:此初始化程序作为分部类手动添加到Xamarin.MacAppKit框架中(API 生成器中的某些内容不得与其定义方式不同)。