[string drawInRect: rect
withFont: self.font
lineBreakMode: NSLineBreakByWordWrapping
alignment: NSTextAlignmentCenter];
[((NSString *)[dayTitles objectAtIndex:index]) drawInRect: dayHeaderFrame
withFont: calendarFont
lineBreakMode: NSLineBreakByWordWrapping
alignment: NSTextAlignmentCenter];
In this code I am getting the below warning in iOS 7:
/wm/Traffic_Department/PMCalendar/src/PMCalendarView.m:150:56: 'drawInRect:withFont:lineBreakMode:alignment:' is deprecated: first deprecated in iOS 7.0 - Use -drawInRect:withAttributes:
How do I remove this warning?
Thanks
Try following.
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
While textToDraw is string that you want to draw. I hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With