drawInRect:withFont:lineBreakMode:IOS 7中的对齐弃用

时间:2014-04-17 19:51:27

标签: ios7 cocos2d-iphone drawinrect

我收到了弃用方法的消息。

代码行是这一行:

[string drawInRect:drawArea withFont:uifont lineBreakMode:linebreaks[lineBreakMode] alignment:alignments[hAlignment]];

所以我想用这段代码替换它:

NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;
paragraphStyle.alignment = NSTextAlignmentCenter;

NSDictionary *attributes = @{ NSFontAttributeName: uifont,
                              NSParagraphStyleAttributeName: paragraphStyle};

[string drawInRect:drawArea withAttributes:attributes];

更换后,此处不再显示警告。但是,我的所有文字都是看不见的。例如,我有一个不可见的文本“选项”(但我仍然可以点击它)。

有人可以帮忙吗?

方面

0 个答案:

没有答案