Swift 具有UIViewRepresentable子类的链方法

Swift 具有UIViewRepresentable子类的链方法,swift,swiftui,uiviewrepresentable,Swift,Swiftui,Uiviewrepresentable,我正在尝试使用以下UIViewRepresentable 导入基础 导入快捷键 结构文本视图:UIViewRepresentable{ @绑定变量文本:字符串 变量_可编辑:Bool=true func makeUIView(上下文:context)->UITextView{ 让结果=UITextView() 让font=UIFont(名称:“Menlo”,大小:18) result.font=font 返回结果 } func updateUIView(uiView:UITextView,con

我正在尝试使用以下
UIViewRepresentable

<代码>导入基础 导入快捷键 结构文本视图:UIViewRepresentable{ @绑定变量文本:字符串 变量_可编辑:Bool=true func makeUIView(上下文:context)->UITextView{ 让结果=UITextView() 让font=UIFont(名称:“Menlo”,大小:18) result.font=font 返回结果 } func updateUIView(uiView:UITextView,context:context){ uiView.text=文本 uiView.isEditable=\u可编辑 } 变异函数可编辑(editable:Bool)->TextView{ _可编辑=可编辑 回归自我 } } 您会注意到我希望在SwiftUI结构中使用的mutating func
editable
,如下所示:

返回ZStack(对齐:对齐.尾随){
TextView(文本:绑定($note.content)!)
.editable(true)//这些“链接方法”不应该是变异的。如果查看可以在SwiftUI框架中链接的方法,则没有一个标记为
变异的

这些方法应该返回结构的一个新实例,并更改某些属性

i、 e.像这样:

func editable(_ editable: Bool) -> TextView {
    // This is a new instance of the struct, but _editable is changed to the new value
    TextView(text: $text, _editable: editable) 
}

很有道理!谢谢
func editable(_ editable: Bool) -> TextView {
    // This is a new instance of the struct, but _editable is changed to the new value
    TextView(text: $text, _editable: editable) 
}