0

I am getting problem in displaying the NSMutableAttributedString in iOS 7.0 where as working well in other versions. Specially this problem is due to stroke colour when map_zoomLevel value increases over 14, when i remove stroke colour from it, it is working perfectly. Why this is happening i don't know. Please help. The code that giving me problem is below-

NSMutableParagraphStyle *mutParaStyle=[[NSMutableParagraphStyle alloc] init];
[mutParaStyle setAlignment:NSTextAlignmentCenter];

NSMutableAttributedString *attStr=[[NSMutableAttributedString alloc]initWithString:_title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontsize+((map_zoomLevel-4)*1.2)],NSParagraphStyleAttributeName:mutParaStyle,NSForegroundColorAttributeName:[UIColor whiteColor],NSStrokeColorAttributeName:[UIColor whiteColor]}];

[attStr drawInRect:CGRectMake(0,_playMapPin.frame.origin.y+_playMapPin.frame.size.height+1, 200, 100)];

You can assume _playMapPin's frame whatever you want.

Ravi Gupta
  • 175
  • 2
  • 11
  • Doesn't answer your question, but `NSAttributedString`/string drawing is utterly buggy and broken since iOS 7. For example, setting a paragraph can break rendering in some cases and using a custom font sometimes breaks measuring the string size. Some bugs have been fixed in iOS 7.1 but lots are left. – DarkDust May 05 '14 at 10:28
  • So as a first test, you might want to try removing the paragraph style and see whether it's drawing correctly then (apart from being left aligned instead of centered, of course). – DarkDust May 05 '14 at 10:30
  • So what can be the alternate for this. – Ravi Gupta May 05 '14 at 11:23
  • see my other question for more information http://stackoverflow.com/questions/23429386/map-annotation-title-not-showing-in-ios-7-0-but-showing-in-6-0-and-7-1 – Ravi Gupta May 05 '14 at 11:24
  • You'll have to work around that bug by changing your design so you can avoid using the stroke color. – DarkDust May 05 '14 at 11:29
  • 1
    AFAIK using CoreText works fine. It's a lot more work to do the drawing this way but seems to be only viable option if you still want to render your outline text. – DarkDust May 05 '14 at 11:30

0 Answers0