Xcode4 尝试将我的项目更新为ios 7错误-drawInRect已被否决
我正在尝试更新我的应用程序以在IOS 7上工作,但收到一个错误,告诉我以下代码已被弃用并与属性一起使用。苹果开发者网站只是说它已经被弃用了,但没有给出如何修复的线索。有人能把我的代码翻译成任何新的格式吗Xcode4 尝试将我的项目更新为ios 7错误-drawInRect已被否决,xcode4,ios7,Xcode4,Ios7,我正在尝试更新我的应用程序以在IOS 7上工作,但收到一个错误,告诉我以下代码已被弃用并与属性一起使用。苹果开发者网站只是说它已经被弃用了,但没有给出如何修复的线索。有人能把我的代码翻译成任何新的格式吗 [str drawInRect: r withFont: f1 lineBreakMode: NSLineBreakByWordWrapping alignment: NSTextAlignmentCenter]; 使用以下命令: NSMutableParagra
[str drawInRect: r
withFont: f1
lineBreakMode: NSLineBreakByWordWrapping
alignment: NSTextAlignmentCenter];
使用以下命令:
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
paragraphStyle.alignment = NSTextAlignmentCenter;
[str drawInRect:rect withAttributes: @{NSFontAttributeName: f1,
NSParagraphStyleAttributeName: paragraphStyle }];
试试下面的
NSString *font = @"Courier-Bold";
#ifdef __IPHONE_7_0
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
paragraphStyle.alignment = NSTextAlignmentCenter;
[textToDraw drawInRect:renderingRect withAttributes: @{NSFontAttributeName: font,
NSParagraphStyleAttributeName: paragraphStyle }];
#else
[textToDraw drawInRect:renderingRect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter];
#endif
textToDraw是要绘制的字符串。我希望这会有帮助。您是否尝试过
drawInRect:withAttributes:
?