简体   繁体   English

Xcode Interface Builder为按钮设置高亮显示的图像

[英]Xcode Interface Builder set highlighted image for button

I'm making an cocoa application from Mac OS X, not for iphone. 我正在从Mac OS X制作一个cocoa应用程序,而不是用于iphone。

I am able to set the background image of a button and uncheck bordered in the attribute inspector. 我可以设置按钮的背景图像,并在属性检查器中取消选中边框。 However, I do not know how I set the image for when you click on it (highlighted/on click, whatever you want to call it). 但是,我不知道当你点击它时我是如何设置图像的(突出显示/点击,无论你想要什么叫它)。 I want to do this because 我想这样做是因为

I have found guides on google to do this with UIbutton but this isn't helpful since I'm making this for Mac. 我已经在谷歌上找到了使用UI按钮执行此操作的指南,但这没有用,因为我正在为Mac制作此功能。

I am using InAppStoreWindow and the button is in the Title bar. 我正在使用InAppStoreWindow ,按钮位于标题栏中。 When I click on the button with the custom image, the background goes white: 当我单击带有自定义图像的按钮时,背景变为白色: 自定义背景与白色按钮

Thank you very much! 非常感谢你!

You are getting white background when button is clicked because You're using incorrect type. 单击按钮时,您将获得白色背景,因为您使用的是不正确的类型。 You need to change button's type to Momentary Change . 您需要将按钮的类型更改瞬时更改 You can change it in Attributes inspector : 您可以在“ 属性”检查器中更改它:

怎么做

Or change programatically: 或以编程方式更改:

[buttonOutlet setButtonType:NSMomentaryChangeButton];


And for highlighting : just add another image as alternate image in Attributes Inspector and it will be shown when button pressed. 并且用于突出显示 :只需在“ 属性”检查器中将另一个图像添加为备用图像,按下按钮时将显示该图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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