开发者

convert NSButton with text to NSButton with image swift

开发者 https://www.devze.com 2022-12-07 21:08 出处:网络
I have a button that has a text label. I would like to use a image for my Asset directory instead however I am not sure how

I have a button that has a text label. I would like to use a image for my Asset directory instead however I am not sure how

current code block

 if let button = self.statusBarItem.button {
      button.action = #selector(togglePopover(开发者_开发百科_:))
      button.title = "ELMC Bridge"
    }

What I have tried to get image as button label

 if let button = self.statusBarItem.button {
      button.action = #selector(togglePopover(_:))
      button.image:("logo132")
    }


Try using setimage propery:

if let button = self.statusBarItem.button {
    button.action = #selector(togglePopover(_:))
    let image = NSImage(named: "logo132")
    button.setImage(image)
}
0

精彩评论

暂无评论...
验证码 换一张
取 消