是否可以使用drawInRect绘制两行文本:withAttributes:?

时间:2013-11-05 23:06:54

标签: ios objective-c nsstring

是否可以使用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}];

那么两行文字会重叠。有没有办法在标题下面绘制副标题?

0 个答案:

没有答案
相关问题