【发布时间】:2013-09-27 16:42:06
【问题描述】:
在我的应用程序的 iOS 5 版本中:
[self.text drawInRect: stringRect
withFont: [UIFont fontWithName: @"Courier" size: kCellFontSize]
lineBreakMode: NSLineBreakByTruncatingTail
alignment: NSTextAlignmentRight];
我正在升级 iOS 7。不推荐使用上述方法。我现在使用 drawInRect:withAttributes:。 attributes 参数是一个 NSDictionary 对象。我可以使用 drawInRect:withAttributes: 为前一个 font 参数工作:
UIFont *font = [UIFont fontWithName: @"Courier" size: kCellFontSize];
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: font, NSFontAttributeName,
nil];
[self.text drawInRect: stringRect
withAttributes: dictionary];
我要向 dictionary 添加哪些键值对来获得 NSLineBreakByTruncatingTail 和 NSTextAlignmentRight?
【问题讨论】: