Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I put multiple lines of text in an NSMenuItem?

I would like to create an NSMenuItem with more than one line of text in it, and I'd also like an icon to appear next to both lines of text. I can't use a custom view, because then it wouldn't highlight correctly, and I can't just put a newline in the menu item's title, because the newline gets turned into a space. What should I do?

like image 639
tbodt Avatar asked Mar 22 '16 23:03

tbodt


1 Answers

It turns out that although you can't put a newline in the title property of a menu item, you can put a newline in the attributedTitle. Something like this will work:

item.attributedTitle = [[NSAttributedString alloc] initWithString:@"line 1\nline 2"];
like image 162
tbodt Avatar answered Nov 15 '22 07:11

tbodt