Dictionary 无法在UIText.textStorage的setAttributes()中使用字典
在Swift1中,我可以称之为:Dictionary 无法在UIText.textStorage的setAttributes()中使用字典,dictionary,swift2,Dictionary,Swift2,在Swift1中,我可以称之为: func selectParagraphAlignment(newAlignment:NSTextAlignment) { var selectedRange = textView.selectedRange var newParagraphStyle = NSMutableParagraphStyle() newParagraphStyle.alignment = newAlignment var dict = [NSPara
func selectParagraphAlignment(newAlignment:NSTextAlignment) {
var selectedRange = textView.selectedRange
var newParagraphStyle = NSMutableParagraphStyle()
newParagraphStyle.alignment = newAlignment
var dict = [NSParagraphStyleAttributeName: newParagraphStyle]
textView.textStorage.beginEditing()
textView.textStorage.setAttributes(dict, range: selectedRange)
textView.textStorage.endEditing()
}
在Swift2中,我不能在textView.textStorage.setAttributes()中使用Distionary。我看不见,我现在必须用什么
你能告诉我新的语法吗?
TIA它可以工作。只是现在textView.textStorage是可选的,否则它仍然是一样的,我无法重现您的问题。@Eric:好的,解决了这个问题。;-)但我在这里遇到了麻烦,我必须问另一个问题:-(