Center Icons in NSMenuItem - objective-c

I have the following menu with items that show the icon on the left side.
I know that it is a OS X default to have so much white on the left side, but I want to have the icons centered in the middle between the text and the edge.
Is there a way to center these icons ?

That space on the left is for the state of the menu item, represented by markers such as check marks and dashes. Short of subclassing NSMenuItem, you're not going to be able to remove that space.
You still have the option to set your own view for each of the menu items. In it, you can position the image and the text the way you want them.
See Apple's documentation for NSMenuItem.
Their documentation Introduction to Application Menus and Pop-up Lists is informative as well.

Related

UWP menu without hamburger

This is my first UWP app
I have a SplitView. On the right side I want a menu. On the left side I want to be able to load different pages into it(frame)
The only menu I can find have that hamburger in it(AppBarButton).
This app will only run on windows desktop machines so I do not have need of the hamburger and it will be rather useless.
I have spent the last two nights looking for options but all I get are hamburgers.
Can someone please point me to an example of a no hamburger menu or a tutorial of some kind?
I am sure I can figure it out once I know what elements to use, I just need a push in the correct direction.
What you need is a base page (let's call it "HostView") this will simply have a SplitView control with the DisplayMode set to Inline and the IsPaneOpen set to true. You can also set the side panel width by using the OpenPaneLength property.
Your menu buttons go into the SplitView.Pane and you place a Frame control in the SplitView.Content. This frame will navigate to the correct page when a menu item is selected.
If you set the properties as I said above then you will not need a Hamburger menu to open the side panel at all. However, please consider the fact that users will want to resize your app, and they might resize to a very narrow size which means it might not have enough space to display all the content. IN which case you will need to collapse the side panel and show a hamburger menu to open it when needed. You don't have to do this, but it is something to consider.

Yosemite Toolbar Style

How do I get the new toolbar item style of OSX Yosemite?
I created a standard toolbar, but the buttons don't have that button-like look. Do I need to drag actual buttons to the toolbar to get this look?
What I have:
What I want (that round bezel and white background):
There are two types of items in toolbars, image items and view items. It looks like you have an image item. You seem to want a view item where the view is an NSButton configured as a round textured button. So, yes, you should drag actual buttons to the toolbar.
I would not attempt to control the button background. You should use the button as-is to get the default system appearance. Apple recommends using a PDF template image (all black with the alpha channel used to make the image). The button itself would not have a title/label. Rather that would be on the containing toolbar item.
It looks like you may have applied an internal blue "glow" or highlight to your image. Generally, you should not do that. Let the frameworks apply appropriate effects to the template image automatically based on the button state and shows-state-by mode.
Toolbars in the Human Interface Guidelines
Controls which are appropriate to use in the window frame (including the toolbar)
Designing images for toolbar buttons
Works just fine for my Cocoa app under Yosemite -
are you actually setting the template property for your icon images..?
From the NSImage docs:
The 'template' property is metadata that allows clients to be smarter
about image processing. An image should be marked as a template if it
is basic glpyh-like black and white art that is intended to be
processed into derived images for use on screen.

how to align text center in nsMenuItem Cocoa Mac osx

I am new in MAC OS X development, I have to align text centre in nsMenuItem but I not find any particular solution. I checked on google but not find any tutorial.
Find some tutorial but not exactly same, in these tutorial we take a NSView in nsMenuItem and then Insert subview in NSVIEW to accomplish it centre align.
Is there is any better solution? Please provide me link if possible.
Edit : I attached screen shot, but this is not working for me.
Thanks
You can set the Attributed String of the menu item, which does allow you to center the text, as well as change the font, color and size of the text as well.
I do not know which version of Xcode/OSX you are using, but under Xcode 5.0.2 you can use the built-in interface builder to edit the attributed strings of menu items.
Click the MainMenu.xib entry, then click the menu you want to edit to open it, then click the menu entry. On the right side of the window there should be some options, if not click the right most square in the group of 3 at the top right of the Xcode window 1.
Once you have the right panel open click the Attributes Inspector icon [2] (4th from the left, looks like a slider type icon). At the bottom of the list of attributes you will see an entry for "Attrib. Title" [3].
That is where you can set a custom font, color and alignment for your menu item.
If you need more control then that provides, you can also embed custom NSViews into your menus which gives you complete control over how the menu will look.

How to make a tab bar that shows colored icons , on iOS?

I need to make a toolbar on the bottom of the screen with some buttons. I want in every button to have a small image and a small text under it. The closest i can find from "Xcode" is the "Tab Bar" where you can put icons and text but the problem is that when you add an image you can only see the shadow of the image and not its colors.. Can i change that? Or is another way to make a toolbar like the one i am describing?
EDIT
I need the buttons to change controllers and i just noticed that i cant create actions for the tabs but only outlets. So i guess the tab bar is not what i should use. Any ideas for a toolbar?
Yes Tab Bar is the Best approach for it and it is very easy to customize the tab bar if u are using IO5
This LINK will be helpful.
There is another approach (which was applicable uptil IOS4 for customization of Tab bar) was to Create Custom buttons with tab bar look alike Images. it will give u the same feel, but like i said it is very easy now to customize IOS Tab bars
Here is a couple of Links for u
LINK 1 With Story BOARD
LINK 2 Without Storyboard
One More thing Try searching Google before Posting a question here if have some problem then feel free to post along with the code or tutorial u tried.
Let me know if i Worked
Cheers
W

How to add icons to the right hand side of NSMenuItem

I'm trying to add some icons to the right hand side of a menu next to a menu item, ideally all right justified. I'm aware that NSMenuItem allows you to add menu items (for instance, see the MenuMadness example). I'm really looking for something like the security / signal strength indicators in the OS X Wifi menu.
One approach that I've seen is to add items to the menu, and use setView to provide an NSView for each item. However, that seems to be more complicated than it should be. Is there a way to just add an icon / multiple icons to the menu?
On the left side of the menu, it's easy, and even possible from Interface Builder.
For the right side, I assume you have read the Apple doc Views in Menu Items. I agree, its far more complicated than it needs to be, with many drawbacks.
Have you considered a hacky workaround?
Just create your menus with no title, and set up an icon that is a very wide icon image, including your title and icon.
You loose the keyboard navigation if the user wants to navigate in your menu by typing the beginning of the menu's title, and it might not work if your titles need to be dynamic, but depending on the context of this feature, it's worth a shot.
Similar to the last item of this menu: