[英]drawInRect: withFont: iOS 7 not working
I was using a library (SGInfoAlert) which uses deprecated code drawInRect:r withFont:. 我正在使用一个库(SGInfoAlert),该库使用已过时的代码drawInRect:r和Font:。 I tried changing some codes to fix it in iOS 7 but the text doesn't show. 我尝试更改一些代码以在iOS 7中修复它,但文本未显示。 Anyone knows why this is happening? 有人知道为什么会这样吗?
// Changed this
//[info_ drawInRect:r withFont:[UIFont systemFontOfSize:kSGInfoAlert_fontSize]];
// To this
NSDictionary *textAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:kSGInfoAlert_fontSize]};
[info_ drawInRect:r withAttributes:textAttributes];
Here is the git repository https://github.com/sagiwei/SGInfoAlert 这是git存储库https://github.com/sagiwei/SGInfoAlert
Ok. 好。 I found a fix. 我找到了解决方法。
// iOS 7 fix
UIFont* font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
NSDictionary *attrs = @{ NSForegroundColorAttributeName : [UIColor whiteColor],
NSFontAttributeName : font,
NSTextEffectAttributeName : NSTextEffectLetterpressStyle};
[info_ drawInRect:r withAttributes:attrs];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.