开发者

How to limit the length of text for labels?

开发者 https://www.devze.com 2022-12-11 06:08 出处:网络
This could开发者_运维技巧 be really easy but I it\'s not obvious when I google it. I have few NSMenuItem items that get populated at runtime and the label can be very long.How do set a limit for the

This could开发者_运维技巧 be really easy but I it's not obvious when I google it.

I have few NSMenuItem items that get populated at runtime and the label can be very long.How do set a limit for the title with the "..." in the middle of the text?


You could write your own method to preprocess the text before it is set to the label, and adds in ... on your own terms.


Another possibility: grab the NSMenuItemCell from the menu item and set its line break mode to NSLineBreakByTruncatingMiddle

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号