nsimageview

Mac OS Cocoa: Draw a simple pixel on a canvas

こ雲淡風輕ζ 提交于 2020-05-09 19:11:31
问题 I wish I would find an answer for this. I have searched and searched and couldn't the right answer. Here is my situation: In a Mac OS Cocoa Application, I want to draw a pixel (actually a few pixels) onto a dedicated area on my application window. I figured, it would be nicer to have a NSImageView placed there (I did so with IB and connected the outlet to my app delegate) and draw on that instead of my NSWindow . How in the world can I do that? Mac OS seems to offer NSBezierPath as the most

macOS High Sierra and CAShapeLayers, NSImageView, NSTableView confilcts

筅森魡賤 提交于 2020-01-03 17:06:51
问题 I have updated to macOS High Sierra and have now unexpected problems in my project, the problems not seen before in macOS Sierra. I have custom NSImageView and after drag and drop of image in this NSImageView I can draw the rectangles on top of the image using CAShapeLayers and mouseDown , mouseDragged function. Then, I can calculate intensities of the image parts inside of the rectangles. The intensities data is in array and this array is used for NSTableView . NSImageView and NSTableView

Resized NSImageView not redrawing

梦想的初衷 提交于 2020-01-03 09:47:07
问题 I have a NSImageView which loads an image from the application bundle. It is setup as such: coverImage.image = [NSImage imageNamed:@"themeSignEnd.png"]; coverImage.imageScaling = NSImageScaleNone; coverImage.imageAlignment = NSImageAlignLeft; The image displays just fine. The size of the NSImageView is calculated based on several other factors and then set using this code: coverImage.frame = CGRectMake((1280 - 869) / 2, 0, 869 * percentage, 800); This works perfectly fine the first time it is

How to create a NSImageView with a rounded corner?

烂漫一生 提交于 2020-01-02 02:35:17
问题 Currently now i want to create a round corner NSImageView,i am a newb,how to ? 回答1: I don't know if this will work so please try it and we'll cross our fingers. On the iPhone you can use the CALayer of any UIView (the NSView counterpart in iOS) to get rounded corners. Based on the reference docs it appears that NSView supports this but again you'll have to try it. Please let me know if it works. NSImageView *view = your view; [view setWantsLayer: YES]; // edit: enable the layer for the view.

Getting bounds of an NSImage within an NSImageView

谁说我不能喝 提交于 2020-01-01 09:08:10
问题 I've got an NSImageView that takes up the full extent of a window. There's no border to the image view, and its set to display in the lower left. So this means that the origin of the view matches the origin of actual image, no matter how the window is resized. Also, the image is much larger than what I can reasonably fit at full scale on the screen. So I also have the imageview set to proportionally scale down the size of the image. However, I can't seem to find this scale factor anywhere. My

mouseEntered and mouseExited not called in NSImageView SubClass

走远了吗. 提交于 2019-12-30 01:36:12
问题 I created a subclass of NSImageView to capture mouseEntered and mouseExited events. But only mouseUp and mouseDown events are getting called. How to capture the mouseEntered and mouseExited events in NSImageView subclass? 回答1: If You want to use mouseEntered: and mouseExited: You need to use NSTrackingArea . Here is reference NSTrackingArea Class Reference. Example: //Add this to Your imageView subclass -(void)mouseEntered:(NSEvent *)theEvent { NSLog(@"Mouse entered"); } -(void)mouseExited:

Can not load NSImageView image from file with NSImage(byReferencingFile: )

白昼怎懂夜的黑 提交于 2019-12-25 18:33:18
问题 When I want to set a image from my disc ( /Users/me/Desktop/image.png ) to the image of my NSImageView with NSImage(byReferencingFile: ) it does not show it. When I try NSImage(named: ) with an image stored in the assets-folder , it works. The code within the viewController class ViewController: NSViewController { @IBOutlet var imageView: NSImageView! override func viewDidLoad() { super.viewDidLoad() imageView.image = NSImage(byReferencingFile: "/Users/me/Desktop/image.png") } } The imageView

Alternative method for canDrawSubviewsIntoLayer prior to OSX 10.9

喜欢而已 提交于 2019-12-24 21:36:05
问题 I needed to implement the following code in my image view to make a gif properly animate: self.homeView.radarImageView.animates = YES; self.homeView.radarImageView.canDrawSubviewsIntoLayer = YES; self.homeView.radarImageView.image = currentData.radarImage; Unfortunately, the canDrawSubviewsIntoLayer method is not compatible with OSX prior to 10.9. Is there an alternative approach that I can use that will make this work in OSX 10.7 and higher? 回答1: avoid layer-based views under 10.8 and below

NSImage returns nil even when png file is in Resource folder

时光总嘲笑我的痴心妄想 提交于 2019-12-24 05:06:35
问题 I'm trying to load an image using NSImage imageNamed: method but i have no success i have copied the image in the project folder: Project>Resources and added to the project using: "Add files to project ..." NSImage* image = [NSImage imageNamed:@"logosH"]; if (image == nil){ NSLog(@"NULL :/"); } NSImageView *accessory = [[NSImageView alloc] initWithFrame:NSMakeRect(0,0,200,55)]; [accessory setImageScaling:NSScaleToFit]; [accessory setImage:[NSImage imageNamed:@"logosH.png"]]; [myAlert

NSImageView double click action

烈酒焚心 提交于 2019-12-22 03:48:19
问题 I have some NSImageView in my Mac App where the user can drag'n drop objects like .png or .pdf, to store them into User Shared Defaults, that works fine. I would now like to set an action for when user double click on these NSImageView, but it seems to be a little bit difficult (I had no trouble for NSTableView, but 'setDoubleAction' is not available for NSImage, and tons of answers (here or with google) concerning NSImageView's actions point to making a NSButton instead of NSImageView, so