From a2ce4b5419ae673cdfca8da4df1d6b0fbc9916d7 Mon Sep 17 00:00:00 2001 From: phlpsong <103433299+phlpsong@users.noreply.github.com> Date: Wed, 3 Jan 2024 22:02:29 +0800 Subject: [PATCH] bugfix: menu item alignment issue (#299) * fix: issue #298 menu item alignment issue * fix: update format * Update Easydict/Feature/StatusItem/EZMenuItemManager.m Co-authored-by: Tisfeng --------- Co-authored-by: Tisfeng --- Easydict/Feature/StatusItem/EZMenuItemManager.m | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Easydict/Feature/StatusItem/EZMenuItemManager.m b/Easydict/Feature/StatusItem/EZMenuItemManager.m index 80a2ba965..ca784ad32 100644 --- a/Easydict/Feature/StatusItem/EZMenuItemManager.m +++ b/Easydict/Feature/StatusItem/EZMenuItemManager.m @@ -326,15 +326,9 @@ - (void)increaseMenuItemHeight:(NSMenuItem *)item lineHeightRatio:(CGFloat)lineH NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; CGFloat fontLineHeight = (font.ascender + fabs(font.descender)); CGFloat lineHeight = fontLineHeight * lineHeightRatio; - NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; - style.minimumLineHeight = lineHeight; - style.maximumLineHeight = lineHeight; - CGFloat baselineOffset = (lineHeight - fontLineHeight) / 2; - - item.attributedTitle = [[NSAttributedString alloc] initWithString:item.title attributes:@{ - NSParagraphStyleAttributeName: style, - NSBaselineOffsetAttributeName: @(baselineOffset) - }]; + // Ref stackoverflow: https://stackoverflow.com/a/18034142/8378840 + NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(1, lineHeight)]; + [item setImage:image]; } - (void)increaseMenuItemsHeight:(NSArray *)itmes lineHeightRatio:(CGFloat)lineHeightRatio {