简体   繁体   中英

Like create a Font Menu as in Microsoft Word in my Mac OSX Cocoa Application

I am Trying to Create a NSComboBox like the image attached with the list of Fonts. Any body knows and custom special control is available.

I have kept the image in dropbox

I see you're new to SO. You say "I'm trying to create", what have you tried? In general on SO you should show what you've attempted, what did not work, what piece of information eluded you, etc.

Here's some information to get you started:

  • NSComboBox justs takes "objects" and says it will display "common value classes" ( ref ). Have you tried NSAttributedString ?

  • NSFontManager has a method availableFonts

You can use those to quickly produce a menu of styled font names, it probably won't be what you want but it will be a start.

Note that on a Mac the recommended ways to select fonts are standard Font menus and the Font Panel ( NSFontPanel ), do you really want to mimic a Windows UI for a Mac app?

HTH

Swift 5.0 🔸

let fonts = NSFontManager.sharedFontManager().availableFonts();
//Then add this array to an NSComboBox component, programtatically or via XCode-Interface-builder 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM