开发者

convert NSButton with text to NSButton with image swift

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜