Ios 是否可以使用drawInRect:withAttributes:绘制两行文本?
是否可以使用Ios 是否可以使用drawInRect:withAttributes:绘制两行文本?,ios,objective-c,nsstring,Ios,Objective C,Nsstring,是否可以使用drawInRect:withAttributes绘制多行文本?我正在创建一个自定义的每日日历视图,该视图将事件显示为带有标题和副标题的彩色块。如果我写 NSMutableParagraphStyle *textStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy]; [textStyle setLineBreakMode:NSLineBreakByTruncatingTail]; [textStyl
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}];
然后两行文字会重叠。有没有办法把副标题画在标题下面 是,使用新位置创建新矩形谢谢,我没有意识到
\u textRect
与彩色块无关@多石的