在我的应用的 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];
我该向字典中添加哪些键-值对,才能获得NSLineBreakByTruncatingTail和NSTextAlignmentRight?