How can I put multiple lines of text in NSMenuItem?

I would like to create an NSMenuItem with multiple lines of text, and I will also like the icon next to both lines of text. I cannot use a custom view because then it will not stand out correctly, and I cannot just put a new line in the title bar, because the new line turns into a space. What should I do?

+5
source share
1 answer

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

 item.attributedTitle = [[NSAttributedString alloc] initWithString:@"line 1\nline 2"]; 
+5
source

Source: https://habr.com/ru/post/1245588/


All Articles