Highlighting only image over button when it is clicked
Right now when I set an image over a button and make it border-less and try to click it, it always shows a rectangular portion highlighted along with the image, which is the actual dim开发者_如何学Goension of button clicked.
My requirement is: I want to highlight only the image over it, not the whole rectangular portion.
Can anyone suggest me some logic to implement it?
In IB, Attribute pane: set Type to Momentary Change.
Different button types highlight differently.
I think this is probably "good enough" for what you are trying to do:
- drag a Gradient Button from the IB palette
- Command-1 for the Attributes view
- untick "Bordered"
- select your image in the "Image" popup menu
This gives you an image-only clickable button that will highly only the image itself when clicked. You can also provide an "alternative image" for the clicked state, but I don't think that will be necessary.
If this isn't quite what you were after, you need to create an IBOutlet link to the NSButtonCell and use:
- (void)setHighlightsBy:(NSInteger)aType
to determine which highlighting method is used.
Full documentation at:
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSButtonCell_Class/Reference/Reference.html#//apple_ref/occ/instm/NSButtonCell/setHighlightsBy:
I hope this helps.
Best regards,
Frank
精彩评论