nsimage

How to write an OS X application that can effect changes (custom cursor, draw an image) even when it is not active?

孤人 提交于 2021-02-10 12:39:57
问题 I previously asked a question about changing the cursor system-wide on OSX. I used NSCursor to change the cursor, but the effects are only as long as the application is active. When another application becomes active, the custom cursor is lost. Here is a related, more general question. How can you write an application to have system-wife effects? For example drawing an image on-screen even when your application is not active, and something else is? I understand I probably need to go at a

How to write an OS X application that can effect changes (custom cursor, draw an image) even when it is not active?

风流意气都作罢 提交于 2021-02-10 12:31:55
问题 I previously asked a question about changing the cursor system-wide on OSX. I used NSCursor to change the cursor, but the effects are only as long as the application is active. When another application becomes active, the custom cursor is lost. Here is a related, more general question. How can you write an application to have system-wife effects? For example drawing an image on-screen even when your application is not active, and something else is? I understand I probably need to go at a

How to write an OS X application that can effect changes (custom cursor, draw an image) even when it is not active?

99封情书 提交于 2021-02-10 12:31:47
问题 I previously asked a question about changing the cursor system-wide on OSX. I used NSCursor to change the cursor, but the effects are only as long as the application is active. When another application becomes active, the custom cursor is lost. Here is a related, more general question. How can you write an application to have system-wife effects? For example drawing an image on-screen even when your application is not active, and something else is? I understand I probably need to go at a

how to code NSButton to look just like image

為{幸葍}努か 提交于 2021-01-26 19:49:36
问题 Using code (not the Interface builder) I need to create an NSButton that looks like an image. Specifically I want to use NSImageNameStopProgressFreestandingTemplate and I need it not to look like button but to look like the image. This means: 1. No 'button down' look 2. No border, no any visibility of the button Thanks. 回答1: I know this response is a bit late, but you could try this, given thisButton : [thisButton setImage:[NSImage imageNamed:NSImageNameStopProgressFreestandingTemplate]];

how to code NSButton to look just like image

痞子三分冷 提交于 2021-01-26 19:43:34
问题 Using code (not the Interface builder) I need to create an NSButton that looks like an image. Specifically I want to use NSImageNameStopProgressFreestandingTemplate and I need it not to look like button but to look like the image. This means: 1. No 'button down' look 2. No border, no any visibility of the button Thanks. 回答1: I know this response is a bit late, but you could try this, given thisButton : [thisButton setImage:[NSImage imageNamed:NSImageNameStopProgressFreestandingTemplate]];

how to code NSButton to look just like image

只谈情不闲聊 提交于 2021-01-26 19:42:31
问题 Using code (not the Interface builder) I need to create an NSButton that looks like an image. Specifically I want to use NSImageNameStopProgressFreestandingTemplate and I need it not to look like button but to look like the image. This means: 1. No 'button down' look 2. No border, no any visibility of the button Thanks. 回答1: I know this response is a bit late, but you could try this, given thisButton : [thisButton setImage:[NSImage imageNamed:NSImageNameStopProgressFreestandingTemplate]];

Drawing Text on Right Side of NSImage - Unwanted Spacing

柔情痞子 提交于 2020-05-17 05:58:24
问题 I'm using the following code to draw text on the right side on an image im.lockFocus() if let context = NSGraphicsContext.current?.cgContext { context.saveGState() let size = text.size(withAttributes: textFontAttributes) context.translateBy(x: imageRect.width-size.height, y: (imageRect.height - size.width) / 2) context.rotate(by: CGFloat.pi / 2) text.draw(at: .zero, withAttributes: textFontAttributes) context.restoreGState() im.unlockFocus() As you can see there is some excessive spacing from

Add CATextLayer on Top of NSImageView

蓝咒 提交于 2020-05-15 21:35:40
问题 I'm trying to display text on top of an NSImage.I use the following code let myTextLayer = CATextLayer() myTextLayer.string = "My text" myTextLayer.foregroundColor = NSColor.cyan.cgColor myTextLayer.frame = self.img_view.bounds self.img_view.layer=myTextLayer; This keeps producing empty NSImageView 回答1: You needs explicitly say NSImageView wantsLayer before use layers, like below self.img_view.wantsLayer = true let myTextLayer = CATextLayer() myTextLayer.string = "My text" myTextLayer

Unable to set Image of NSImageView using file path

浪子不回头ぞ 提交于 2020-04-17 17:55:26
问题 I have hooked to Selection changed event of NSTableView.I need to display the selected image in the imageview func tableViewSelectionDidChange(_ notification: Notification) { let table = notification.object as! NSTableView print(fileArray[table.selectedRow].path); img_view.image=NSImage(named: NSImage.Name(rawValue: fileArray[table.selectedRow].path)) } The console prints /Users/myname/Downloads/435_v9_bc.jpg But the imageview does not display the image. Update 1: print(fileArray[table

How to pull NSImage from NSTextAttachment in NSTextView?

和自甴很熟 提交于 2020-03-06 09:12:55
问题 Goal is to allow user to add NSImage (s) to an NSAttributedString in an NSTextView , and then reverse the process and extract the image(s). With code from here, can add image(s) and have them displayed inline. let attributedText = NSMutableAttributedString(string: string, attributes: attributes as? [String : AnyObject]) let attachment = NSTextAttachment() let imageTest = NSImage(named:"sampleImage") as NSImage? let attachmentCell: NSTextAttachmentCell = NSTextAttachmentCell.init(imageCell: