let btn = NSButton(frame: NSRect(x: 5, y: 5, width: 60, height: 40))
override func awakeFromNib() {
super.awakeFromNib()
btn.title = ""
btn.image = NSImage(named: "image.png")
btn.alternateImage = NSImage(named: "highlighted_image.png")
btn.imageScaling = NSImageScaling.scaleProportionallyDown
//重要なのはこれ↓
btn.setButtonType(NSButton.ButtonType.momentaryChange)
// btn.wantsLayer = true
// btn.layer?.cornerRadius = 12
// btn.isBordered = false
btn.target = self
btn.action = #selector(push)
addSubview(btn)
}
@objc func push() {
print("hey")
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00