NSTextAlignment:无法从objective-c转换为swift
问题描述:
我对此非常失望,但我无法将此代码从objective-c转换为swift。 :-(NSTextAlignment:无法从objective-c转换为swift
五月帮助我的人我不知道,发现什么与谷歌沮丧小时后,我求你帮忙;-)
Objective-C的 - 代码:?(看起来简单[grrrrr])
唯一线,我可以是变换;-(
textView.textStorage .beginEditing()
textView.textStorage .endEditing()
答
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()
}
希望这有助于:D
@Charle: 这看起来很好:-)很多! –
不用担心!希望它的作品! –
是的,它按预期工作:-) –