@@ -383,14 +383,16 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
383383 isTextMode = false ;
384384 NSArray *tmp = [title componentsSeparatedByString: @" ," ];
385385 NSData *decodedData;
386- #ifdef __IPHONE_7_0
386+ #if !defined(__IPHONE_8_0)
387+ decodedData = [[NSData alloc ] initWithBase64Encoding: (NSString *)tmp[1 ]];
388+ #else
387389 if ([PluginUtil isIOS7_OR_OVER ]) {
388- decodedData = [[NSData alloc ] initWithBase64Encoding: (NSString *)tmp[1 ]];
389- } else {
390390 decodedData = [NSData dataFromBase64String: tmp[1 ]];
391+ } else {
392+ #if !defined(__IPHONE_7_0)
393+ decodedData = [[NSData alloc ] initWithBase64Encoding: (NSString *)tmp[1 ]];
394+ #endif
391395 }
392- #else
393- decodedData = [NSData dataFromBase64String: tmp[1 ]];
394396 #endif
395397
396398 base64Image = [[UIImage alloc ] initWithData: decodedData];
@@ -411,15 +413,15 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
411413 }
412414 }
413415 if (isBold == TRUE && isItalic == TRUE ) {
414- if ([PluginUtil isIOS7_OR_OVER ] == true ) {
416+ # ifdef __IPHONE_7_0
415417 // ref: http://stackoverflow.com/questions/4713236/how-do-i-set-bold-and-italic-on-uilabel-of-iphone-ipad#21777132
416418 titleFont = [UIFont systemFontOfSize: 17 .0f ];
417419 UIFontDescriptor *fontDescriptor = [titleFont.fontDescriptor
418420 fontDescriptorWithSymbolicTraits: UIFontDescriptorTraitBold | UIFontDescriptorTraitItalic];
419421 titleFont = [UIFont fontWithDescriptor: fontDescriptor size: 0 ];
420- } else {
422+ # else
421423 titleFont = [UIFont fontWithName: @" Helvetica-BoldOblique" size: 17.0 ];
422- }
424+ # endif
423425 } else if (isBold == TRUE && isItalic == FALSE ) {
424426 titleFont = [UIFont boldSystemFontOfSize: 17 .0f ];
425427 } else if (isBold == TRUE && isItalic == FALSE ) {
@@ -429,14 +431,33 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
429431 }
430432
431433 // Calculate the size for the title strings
432- textSize = [title sizeWithFont: titleFont constrainedToSize: CGSizeMake (mapView.frame.size.width - 13 , mapView.frame.size.height - 13 )];
434+ CGSize tmpSize = CGSizeMake (mapView.frame .size .width - 13 , mapView.frame .size .height - 13 );
435+ #if !defined(__IPHONE_8_0)
436+ textSize = [title sizeWithFont: titleFont constrainedToSize: tmpSize];
437+ #else
438+ NSDictionary *attr = @{ NSFontAttributeName : titleFont};
439+ textSize = [title boundingRectWithSize: tmpSize
440+ options: NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine
441+ attributes: attr
442+ context: nil ].size ;
443+ #endif
433444 rectSize = CGSizeMake (textSize.width + 10 , textSize.height + 22 );
434445
435446 // Calculate the size for the snippet strings
436447 if (snippet) {
437448 snippetFont = [UIFont systemFontOfSize: 12 .0f ];
438449 snippet = [snippet stringByReplacingOccurrencesOfString: @" \n " withString: @" " ];
439- snippetSize = [snippet sizeWithFont: snippetFont constrainedToSize: CGSizeMake (mapView.frame.size.width - 13 , mapView.frame.size.height - 13 )];
450+
451+
452+ #if !defined(__IPHONE_8_0)
453+ snippetSize = [snippet sizeWithFont: snippetFont constrainedToSize: tmpSize];
454+ #else
455+ NSDictionary *attr = @{ NSFontAttributeName : snippetFont};
456+ snippetSize = [snippet boundingRectWithSize: tmpSize
457+ options: NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine
458+ attributes: attr
459+ context: nil ].size ;
460+ #endif
440461 rectSize.height += snippetSize.height + 4 ;
441462 if (rectSize.width < snippetSize.width + leftImg.size .width ) {
442463 rectSize.width = snippetSize.width + leftImg.size .width ;
@@ -574,7 +595,7 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
574595 }
575596
576597 CGRect textRect = CGRectMake (5 , 5 , rectSize.width - 10 , textSize.height );
577- if ([PluginUtil isIOS7_OR_OVER ] == true ) {
598+ # if defined(__IPHONE_7_0)
578599 // iOS7 and above
579600 NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc ] init ];
580601 style.lineBreakMode = NSLineBreakByWordWrapping;
@@ -587,43 +608,41 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
587608 };
588609 [title drawInRect: textRect
589610 withAttributes: attributes];
590-
591-
592- } else {
611+ #else
593612 // iOS6
594613 [titleColor set ];
595614 [title drawInRect: textRect
596615 withFont: titleFont
597616 lineBreakMode: NSLineBreakByWordWrapping
598617 alignment: textAlignment];
599- }
618+ # endif
600619 // CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 0.5);
601620 // CGContextStrokeRect(context, textRect);
602621 }
603622
604623 // Draw the snippet
605624 if (snippet) {
606625 CGRect textRect = CGRectMake (5 , textSize.height + 10 , rectSize.width - 10 , snippetSize.height );
607- if ([PluginUtil isIOS7_OR_OVER ] == true ) {
608- // iOS7 and above
609- NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc ] init ];
610- style.lineBreakMode = NSLineBreakByWordWrapping;
611- style.alignment = textAlignment;
612-
613- NSDictionary *attributes = @{
614- NSForegroundColorAttributeName : [UIColor grayColor ],
615- NSFontAttributeName : snippetFont,
616- NSParagraphStyleAttributeName : style
617- };
618- [snippet drawInRect: textRect withAttributes: attributes];
619- } else {
620- // iOS6
621- [[UIColor grayColor ] set ];
622- [snippet drawInRect: textRect
623- withFont: snippetFont
624- lineBreakMode: NSLineBreakByWordWrapping
625- alignment: textAlignment];
626- }
626+ # if defined(__IPHONE_7_0)
627+ // iOS7 and above
628+ NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc ] init ];
629+ style.lineBreakMode = NSLineBreakByWordWrapping;
630+ style.alignment = textAlignment;
631+
632+ NSDictionary *attributes = @{
633+ NSForegroundColorAttributeName : [UIColor grayColor ],
634+ NSFontAttributeName : snippetFont,
635+ NSParagraphStyleAttributeName : style
636+ };
637+ [snippet drawInRect: textRect withAttributes: attributes];
638+ # else
639+ // iOS6
640+ [[UIColor grayColor ] set ];
641+ [snippet drawInRect: textRect
642+ withFont: snippetFont
643+ lineBreakMode: NSLineBreakByWordWrapping
644+ alignment: textAlignment];
645+ # endif
627646 }
628647 } else {
629648 // Draw the content image
0 commit comments