text.drawInRect(aRectangle, withFont: font, lineBreakMode: .UILineBreakModeTailTruncation, alignment: .Center)
我在.UILineBreakModeTailTruncation中收到错误...所以我该如何解决? 我正在使用Xcode 7,swift 2
我得到另一个错误,这是: ' drawInRect(_:withFont:lineBreakMode:对准:)'不可用..我怎么解决???
谢谢.. !!!
答案 0 :(得分:3)
您传递的枚举值不正确,您应该传递值:
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)