image and text width in a UIButton - xcode

All,
I have an button like this :
i want to give a little more space between the icon and the text.. Is this possible in Interface Builder ?

Yes, select your button and in the attributes inspector you can set the image insets.

Sure, in IB you can configure options Edge Insets for UIButton.
It's well explained in this post, in the The Lazy Coder reply.

Related

Auto expand an NSWindow to fit an NSToolbar using auto layout

I have an NSWindow with an NSToolbar that I present as a sheet. I want the NSWindow to resize to fit the NSToolbar (so the buttons don't get chopped.)
The toolbar is not user configurable, but its size will change due to localisation.
I'm trying to achieve this using auto layout.
Any pointers would be most welcome.
Thanks

NSTextField clicked link colour

I have an NSTextField that contains an NSAttributedString which itself contains a clickable link.
I've change the colour of the link for my own styling, however when I click on it it becomes blue and underlined. How can I stop this?
Seems that I'm not the only one with this problem, and there's a handy class to solve it:
https://github.com/laevandus/NSTextFieldHyperlinks
https://github.com/catlan/DSClickableURLTextField
This (http://developer.apple.com/library/mac/#qa/qa1487/_index.html) may help you. It will show you how to set/change the blue link color and the underlineAttribute. You may also have a look at the methods -linkTextAttributes and -setLinkTextAttributes: of an NSTextView.

Creating NSToolbar style buttons

Is there a bevel style that can replicate NSToolbar style of buttons that are used, for instance, in the Safari's preferences window to switch between different panes?
I need to replicate NSToolbar in an NSView using NSButtons. I understand that I should probably be using NSTabView, but I'd like to implement the look of xcode's left pane. Any tips here would be appreciated greatly.
There's nothing built-in, you'd have to create the images yourself. However, replicating the behaviour is straightforward.
You could simply use a single-row NSMatrix of NSButton objects. Just give the buttons an image and an alternate image (for the highlighted state) and set the matrix mode to NSRadioModeMatrix.

Cocoa: Accessibility (VoiceOver) for buttons with image only

I use NSButton with empty title and image on it, and it cannot be accessed with VoiceOver.
But when I'm setting title (VoiceOver seems to use title), NSButton tries to show it.
I think there should be an easy way to not display title, or to set button text, used by VoiceOver, however quick search didn't give any results yet.
P.S. I'm creating button programmatically.
you must assign the accessibilityLabel to the image object directly, It works this way.
Solved issue - added subclass for NSButtonCell, which does nothing in drawTitle: method and returns NSZeroRect. Seems to work ok.

Can't Edit NSWindow's Toolbar - Cocoa

So I'm using the method:
[someWindow setContentBorderThickness:24.0 forEdge:NSMaxYEdge];
But I can't seem to get the toolbar to increase in height. It simply stays the same as in default. Can anyone shed some light here?
An NSToolbar is automatically resized to accommodate the height of the tallest NSToolbarItem. The standard (large) toolbar items are all 32 px tall, so the toolbar has no need to make itself larger. If you do something like add a custom view toolbar item, then it will be resized to accommodate that item, as shown in the image below:
(To accomplish the result shown above, I clicked on the toolbar twice in IB to bring down the Allowed Toolbar Items sheet, then dragged an NSView custom view from the library palette onto that sheet).
P.S. I'd recommend using this capability with discretion.
You cannot specify an arbitrary height for NSToolbar. You can, however, specify a size mode. A toolbar with 24x24-pixel icons has a small size mode:
[toolbar setSizeMode: NSToolbarSizeModeSmall];
which is equivalent to Size: Small in Interface Builder’s Attributes Inspector.

Resources