Questions tagged [nsview]

NSView Implements basic drawing, event handling and printing behaviors for applications. Usually application code define subclasses of NSView to provide richer implementations. Belongs to the Foundation framework for Cocoa and Cocoa Touch.

The NSView class defines the basic drawing, event-handling, and printing architecture of an app. You typically do not use NSView objects directly. Instead, you use objects whose classes descend from NSView or you subclass NSView yourself and override its methods to implement the behavior you need. For any view object, there are many methods that you can use as-is.

1639 questions
14
votes
1 answer

NSView -dataWithPDFInsideRect: and layer borders

I'm using -dataWithPDFInsideRect: with an NSView that has many subviews. It works fine but doesn't render any of the subview's layer properties like borders. Is there a way to get that to work?
Berry Blue
  • 15,330
  • 18
  • 62
  • 113
13
votes
2 answers

Dragging the view

I have an NSView which I am adding as a sub-view of another NSView. I want to be able to drag the first NSView around the parent view. I have some code that is partially working but there's an issue with the NSView moving in the opposite direction…
PruitIgoe
  • 6,166
  • 16
  • 70
  • 137
13
votes
3 answers

How I set the default position of a NSScroll view?

I have a trouble with a NSScrollview in my aplication because it always start at the bottom of the window. How could make it start in the top?
Javier Beltrán
  • 756
  • 5
  • 26
13
votes
2 answers

Custom NSView with rounded corners and drop shadow

I'm trying to create a custom NSView with both rounded corners and a drop shadow. I created an NSView subclass and have the following drawRect: method - (void)drawRect:(NSRect)dirtyRect { NSRect rect = NSMakeRect([self bounds].origin.x + 3,…
Lou Howard
  • 131
  • 1
  • 1
  • 3
13
votes
1 answer

iOS Charts Pie Chart Size

I am using iOS Charts with Swift 3. I have a 100 x 100 PieChartView that renders the pie chart, but it's not filling the view (an NSView, to be precise). The gray box is the view and there's a large gap between the pie and the edge. I have…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
13
votes
3 answers

How to display shadow for NSView?

I have gone through many threads here and other blogs but not able to solve this issue. I have a added a subview in content view of window. Here is the storyboard-- - I have dragged out outlet of customView to view controller and here is the code…
Abhishek
  • 852
  • 9
  • 24
13
votes
3 answers

Layer backed NSView with custom CALayer not calling updateLayer?

I have a custom layer-backed NSView and have overidden the makeBackingLayer method to return a custom CALayer subclass. I have also overriden wantsUpdateLayer to return true thereby fully opting into layer-like drawing. override func…
Sam
  • 2,745
  • 3
  • 20
  • 42
13
votes
4 answers

NSButton mouseDown mouseUp behaving differently on enabled

If the NSButton is not enabled, the mouseDown: and mouseUp: behave as expected (so when the mouse is pushed down, the mouseDown: is called, and when it is released, the mouseUp: is called) However, if the NSButton IS enabled, than the mouseUp:…
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
13
votes
4 answers

Drawing selection box (rubberbanding, marching ants) in Cocoa, ObjectiveC

I've currently implemented a simple selection box using mouse events and redrawing a rectangle on mouse drag. Here's my code: -(void)drawRect:(NSRect)dirtyRect { if (!NSEqualRects(self.draggingBox, NSZeroRect)) { [[NSColor grayColor]…
John Smith
  • 363
  • 3
  • 13
13
votes
4 answers

Replacing NSView while keeping autolayout constraints

I want to replace one NSView to other view while keeping the constraints. I have a superview, subview as it's child and an placeholder that I'm planning to move to subview's place. But it seems like the code [[superview] replaceSubview:subview…
ULazdins
  • 1,975
  • 4
  • 25
  • 31
13
votes
4 answers

Starting Position of NSSplitView divider

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…
aroooo
  • 4,726
  • 8
  • 47
  • 81
12
votes
3 answers

Getting the center point of an NSView

I need to get the center point of a NSView in the form of a CGPoint, how can I achieve this? I am basically looking for the equivalent of the UIKit, UIView.center
foobar5512
  • 2,470
  • 5
  • 36
  • 52
12
votes
2 answers

Cocoa NSView subview blocking drag/drop

I have an NSView subclass which registers for drag files in init method like this: [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]]; The drag drop works perfectly fine, but if I add a subview to this view with the…
user635064
  • 6,219
  • 12
  • 54
  • 100
12
votes
7 answers

Get ALL views and subview of NSWindow

Is there a way I can get ALL the views and subviews and subviews of these subviews (you get the idea...) of an NSWindow? Thanks.
user635064
  • 6,219
  • 12
  • 54
  • 100
12
votes
4 answers

How to add a blurred view ontop of a view?

I have an NSTableView that gets reloaded. While new data is loading, I want to add a subview ontop of it with a spinner. I would like the view ontop to be semi-transparent and reveal the view beneath it, to be blurred. How would I go about doing…
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556