是否可以使用drawInRect:withAttributes
绘制多行文字?我正在创建一个自定义日常日历视图,将事件显示为带有标题和副标题的彩色块。如果我要写
NSMutableParagraphStyle *textStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
[textStyle setLineBreakMode:NSLineBreakByTruncatingTail];
[textStyle setAlignment:NSTextAlignmentLeft];
[[self title] drawInRect:_textRect withAttributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:FONT_SIZE], NSParagraphStyleAttributeName: textStyle}];
[[self subtitle] drawInRect:_textRect withAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:FONT_SIZE], NSParagraphStyleAttributeName: textStyle}];
那么两行文字会重叠。有没有办法在标题下面绘制副标题?