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
162
votes
18 answers

Best way to change the background color for an NSView

I'm looking for the best way to change the backgroundColor of an NSView. I'd also like to be able to set the appropriate alpha mask for the NSView. Something like: myView.backgroundColor = [NSColor colorWithCalibratedRed:0.227f …
BadPirate
  • 25,802
  • 10
  • 92
  • 123
57
votes
1 answer

Layer-backed NSView rotation and skewed siblings

I have a strange issue with layer-backed NSView and it's siblings, some of them are not rendered correctly when added into the existing view hierarchy attached to the rotated superview. Below are the details. The problem - NSScrollView (layer can be…
Gobra
  • 4,263
  • 2
  • 15
  • 20
44
votes
5 answers

NSView's bounds vs frame

What's the difference between bounds and frame? In fact, why does 'bounds' even exist? The size of 'bounds' is equal to the frame's size, and the bound's origin should always be 0,0.
AWF4vk
  • 5,810
  • 3
  • 37
  • 70
40
votes
4 answers

Does NSView have anything analogous to UIView's setNeedsLayout/layoutSubviews methods?

Do I put such things into the display method? Or is there something analogous?
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
40
votes
7 answers

How do I make an NSView move to the front of all NSViews

I have a super view, which has 2 subviews. These subviews are overlapped. Whenever i choose a view from a menu, corresponding view should become the front view and handle actions. i.e., it should be the front most subview. acceptsFirstResponder…
Dhanaraj
  • 987
  • 1
  • 10
  • 26
39
votes
2 answers

Embed font in a mac bundle

I have a program I am writing. I want to use a fancy font. Can I just embed my font into my bundle and use it from there. My code... NSMutableAttributedString *recOf; recOf = [[NSMutableAttributedString alloc] initWithString:@"In Recognition…
RW.
  • 637
  • 6
  • 14
34
votes
2 answers

Cocoa drawing on different screens loses performance

I have a document-based app, where each document has one window with an NSScrollView that does some (fairly continuous) drawing using only Cocoa. To call the drawing, I am using a CVDisplayLink, outlined in the code below: -…
spudwaffle
  • 2,905
  • 1
  • 22
  • 29
33
votes
9 answers

Selection Highlight in NSCollectionView

I have a working NSCollectionView with one minor, but critical, exception. Getting and highlighting the selected item within the collection. I've had all this working prior to Snow Leopard, but something appears to have changed and I can't quite…
33
votes
4 answers

How can I create Yosemite-style view with translucent/blurry background?

In Yosemite sidebars have a semitransparent "vibrant" background. How can I create a view like that in 10.10/Xcode 6? Can I give any view such background? I've found that NSOutlineView will default to such background when you give it "Source list"…
Kornel
  • 97,764
  • 37
  • 219
  • 309
32
votes
11 answers

NSWindow with round corners and shadow

I'm trying to crate a NSWindow without title bar (NSBorderlessWindowMask) with round corners and a shadow, similar to the below "Welcome to Xcode" window. I make a subclass of NSWindow: @implementation FlatWindow -…
dhrm
  • 14,335
  • 34
  • 117
  • 183
25
votes
6 answers

Make NSView NOT clip subviews outside of its bounds

Is it possible to make an NSView not clip its subviews that are outside of the bounds? On iOS I would simply set clipsToBounds of my UIView no NO. But NSView doesn't have such a property. I tried experimenting with wantsLayer, masksToBounds,…
DrummerB
  • 39,814
  • 12
  • 105
  • 142
23
votes
10 answers

Setting backgroundColor of custom NSView

What is the process of drawing to NSView using storyboards for osx? I have added a NSView to the NSViewController. Then, I added a few constraints and an outlet. Next, I added some code to change the color: import Cocoa class ViewController:…
slcott
  • 1,194
  • 3
  • 14
  • 26
21
votes
3 answers

Rounded rect on NSView that clips all containing subviews

I am creating a NSView subclass that has rounded corners. This view is meant to be a container and other subviews will be added to it. I am trying to get the rounded corners of the NSView to clip all of the subview's corners as well, but am not able…
coneybeare
  • 33,113
  • 21
  • 131
  • 183
21
votes
6 answers

How to find if the mouse is over a view

I need to find if the mouse position is inside an NSView's rect. I'd use NSPointInRect(point, rect), but I'd need to convert the rect coordinates to screen coordinates and I'm not sure how. Any help would be much appreciated!
Arlen Anderson
  • 2,486
  • 2
  • 25
  • 36
21
votes
2 answers

Animate Auto Layout Constraints and Alpha on NSView

Swift 3, iOS 10, macOS 10.12.4 I am building an app that runs on both iOS and Mac. On the iOS side, I have successfully animated a UIView. When the user taps on something, a popup appears and animates into position. Here's my code inside the tap…
Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128
1
2 3
99 100