text.drawInRect(aRectangle, withFont: font, lineBreakMode: .UILineBreakModeTailTruncation, alignment: .Center)
我在.UILineBreakModeTailTruncation中得到错误。。。那我该怎么解决呢???
我在和Xcode 7,swift 2一起工作
我又犯了一个错误,那就是:
'drawInRect(\u:withFont:lineBreakMode:alignment:)'不可用。。我该怎么解决??
谢谢。。!!!
最佳答案
传递的枚举值不正确,应传递如下值:
text.drawInRect(aRectangle, withFont: font, lineBreakMode: .TailTruncation, alignment: .Center)
或
text.drawInRect(aRectangle, withFont: font, lineBreakMode: UILineBreakMode.TailTruncation, alignment: .Center)
供参考
UILineBreakMode is deprecated(从iOS 6开始),您应该改用NSLineBreakMode。因此,上述代码更改为:
text.drawInRect(aRectangle, withFont: font, lineBreakMode: .ByTruncatingTail, alignment: .Center)
或
text.drawInRect(aRectangle, withFont: font, lineBreakMode: NSLineBreakMode.ByTruncatingTail, alignment: .Center)