nsview

Layering Cocoa WebView - Drawing on top?

扶醉桌前 提交于 2019-12-07 05:08:06
问题 webview in core animation layer The only other thread I can find is the above which doesn't necessarily fit my needs. Is there a reliable way to simply draw a view on top of a webview? I've tried to layer a regular NSView on top of WebView, and it draws right at first, but any movement in the webview (scrolling the page etc) appears to invalidate the view and produces visual artifacts. I've tried: [[[NSApp mainWindow] contentView] addSubview:view positioned:NSWindowAbove relativeTo:webView];

rounded corners on NSView using NSBezierPath are drawn badly

雨燕双飞 提交于 2019-12-07 05:02:30
问题 In my ViewController's main NSView, I override the func drawRect(dirtyRect: NSRect) method to implement rounded corners on my main view using NSBezierPath . In that same method I also designate the gradient background of my main view. override func drawRect(dirtyRect: NSRect) { let path: NSBezierPath = NSBezierPath(roundedRect: self.bounds, xRadius: 18.0, yRadius: 18.0) path.addClip() let gradient = NSGradient(startingColor: NSColor(hexColorCode: "#383838"), endingColor: NSColor(hexColorCode:

Disable clicks on a NSView

妖精的绣舞 提交于 2019-12-07 03:08:08
问题 I know that on a NSWindow you can use setIgnoresMouseEvents: . However, a NSView doesn't have either setEnabled: or setIgnoresMouseEvents: . Any fixes? 回答1: Implement the hitTest: method to return nil . 来源: https://stackoverflow.com/questions/6543240/disable-clicks-on-a-nsview

Resizing nspopover

匆匆过客 提交于 2019-12-07 00:49:34
I am trying to resize an NSPopover prior to displaying it by setting the frame of the NSView it contains using the method: setFrameSize: However, when I try to display the popover by calling: showRelativeToRect: ofView: preferredEdge: The view returns to its previous size. Why is this happening? Is there another way I should be sizing the popover? Thanks in advance, Ben. There's a setContentSize on the popover, but I have the impression this doesn't work so well. I mean it works, but resizes the content (including child views). So the better way is to create a new NSViewController and assign

Adding border and Rounded Rect in the NSView

拥有回忆 提交于 2019-12-06 19:29:55
问题 In my Application , NSView should have rounded rect and border, i tried following static CGColorRef CGColorCreateFromNSColor (CGColorSpaceRef colorSpace, NSColor *color) { NSColor *deviceColor = [color colorUsingColorSpaceName: NSDeviceRGBColorSpace]; float components[4]; [deviceColor getRed: &components[0] green: &components[1] blue: &components[2] alpha: &components[3]]; return CGColorCreate (colorSpace, components); } and in InitWithframe added following lines of Code [[self layer]

Starting Position of NSSplitView divider

邮差的信 提交于 2019-12-06 18:54:05
问题 How can I set the start position of a NSSplitView? The closest thing I've found that looks like it would work is setPosition //Set splitView position. [splitView setPosition:330 ofDividerAtIndex:0]; This doesn't seem to do anything though, my splitview still starts with the divider in the center. ANy ideas? 回答1: Maybe that is the center? If splitView is correctly hooked up to your split view, that code should work. You should probably log [splitView minPossiblePositionOfDividerAtIndex:0] and

NSProgressIndicator in NSStatusItem

孤人 提交于 2019-12-06 15:44:41
问题 I have NSStatusItem with a custom NSView which shows images. Whether the menu is opened or not it show different images just like that: isMenuVisible = NO; - (void)awakeFromNib { statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; [statusItem retain]; dragStatusView = [[DragStatusView alloc] init]; [dragStatusView retain]; dragStatusView.statusItem = statusItem; [dragStatusView setMenu:statusMenu]; [dragStatusView setToolTip:NSLocalizedString(@

Cocoa - loading a view from a nib and displaying it in a NSView container , as a subview

筅森魡賤 提交于 2019-12-06 13:24:08
I've asked about this earlier but the question itself and all the information in it might have been a little confusing, plus the result i want to get is a little more complicated. So i started a new clean test project to handle just the part that im interested to understand for the moment. So what i want, is basically this: i have a view container (inherits NSView). Inside, i want to place some images, but not just simple NSImage or NSImageView, but some custom view (inherits NSView also), which itself contains a textfield and an NSImageView. This 'image holder' as i called it, is in a

Clear NSView programmatically in swift

旧城冷巷雨未停 提交于 2019-12-06 11:56:05
I have a NSView connected to a custom class. There's some drawing on that view: class LineDrawer: NSView { var linear = NSBezierPath() var storage = NSUserDefaults.standardUserDefaults() override func drawRect(dirtyRect: NSRect) { var color = NSColor() if let newLoadedData = storage.objectForKey("color") as? NSData { if let currentColor = NSUnarchiver.unarchiveObjectWithData(newLoadedData) as? NSColor { color = currentColor } } color.set() linear.lineWidth = CGFloat(storage.integerForKey("width")) linear.stroke() } override func mouseDown(theEvent: NSEvent) { super.mouseDown(theEvent) let

How exactly does an NSView, an NSViewController, and MainMenu.xib fit together?

十年热恋 提交于 2019-12-06 11:35:44
问题 I'm going to cut right to the chase: my application has grown quite a bit, and now I think it's time for me to do some tidying up. I want to separate some of my views from my MainMenu.xib file into their own Nib file. The part that's tripping me up is the whole "Interface Builder + My Code" thing. Here's what I've done so far: I've added a view controller proxy object: In the Identity inspector, I've added my view controller's class name to the Custom Class field. In the Attributes inspector,