nsview

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

馋奶兔 提交于 2019-12-10 10:56:14
问题 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),

NSView initialization: -init: vs. -awakeFromNib:

自古美人都是妖i 提交于 2019-12-09 17:21:16
问题 I have a simple class MyView inherited from NSView and instance variable NSImage * image; in it. Class functionality is to draw image on the view. However, in -drawRect: image instance always equal nil , if it was initialized in -init: function and not nil if it was initialized in -awakeFromNib: . Log shows both -init: and -awakeFromNib: functions are called only once. Does -awakeFromNib: reinitialize GUI component by default? 回答1: No. There is no default implementation for awakeFromNib .

How to draw a transparent NSScroller

岁酱吖の 提交于 2019-12-09 13:09:32
问题 I'm subclassing NSScroller to try to make it look similar to how "scrollbars" look on iOS. I want it to just be an overlay representing the current position that is drawn OVER what is under it. For whatever reason if I override drawRect for the scroller, I get the bounds filled with white. Is there any way to prevent this so that way I can just be drawing on top of what my NSScroller sub class is over? Edit: Drawing with clear color seems to bring me close, but it is drawing "too clear" :P It

Using NSProgressIndicator inside an NSMenuItem

自作多情 提交于 2019-12-09 11:25:46
问题 I'm trying to use a NSProgressIndicator (indeterminate) inside of a statusbar-menu. I'm using an NSView-object as view for the menuitem, and then subviews the progress indicator to display it. But whenever i try to call the startAnimation: for the progress, nothing happens. When i try do the very same thing on a normal NSWindow it works perfectly, just not when inside a menuitem. I'm new to both cocoa and objective-c so I might've overlooked something "obvious" but I've searched quite a bit

NSView Remove after animation

十年热恋 提交于 2019-12-09 07:41:31
I do not know why it is proving to be so difficult, but basically I want to animate an NSView across my screen, and once it is done that animation, remove that NSView. It however seems that I can find absolutely no reference on how to do this. Can someone please help? I am starting my animation like this NSRect frame = blob.frame; frame.origin.x = animationStopX; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:timeToDisappear]; [[blob animator] setFrame:frame]; [NSAnimationContext endGrouping]; I have no way of getting a callback from this once it completes

NSView added to NSStatusItem button has an opaque border

こ雲淡風輕ζ 提交于 2019-12-08 06:35:58
问题 I have been working on a NSStatusItem user agent that adds a NSView subclass as a subview of NSStatusItem.button to provide animated icons. When left clicking on the icon, there is a noticeable opaque border around the view. The view subclass's init reads: - (instancetype)initWithFrame:(NSRect )rect { self = [super initWithFrame:rect]; if ( self ) { self.wantsLayer = YES; self.layer.opaque = NO; [self.layer addSublayer:self.background]; [self.layer addSublayer:self.foreground]; [self.layer

NSView Remove after animation

余生长醉 提交于 2019-12-08 06:15:20
问题 I do not know why it is proving to be so difficult, but basically I want to animate an NSView across my screen, and once it is done that animation, remove that NSView. It however seems that I can find absolutely no reference on how to do this. Can someone please help? I am starting my animation like this NSRect frame = blob.frame; frame.origin.x = animationStopX; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:timeToDisappear]; [[blob animator] setFrame

Create Drop Shadow for NSView - Cocoa

﹥>﹥吖頭↗ 提交于 2019-12-08 04:39:12
问题 I'm trying to create a drop shadow surrounding the NSView like how NSWindow does it with its shadow, but I'm having some difficulty. I created a class for the NSView I'm creating the drop shadow for and I'm using this code for the overriding method: -(void)drawRect:(NSRect)dirtyRect { NSRect rect = NSInsetRect([self bounds], 10.0, 10.0); NSShadow *dropShadow = [[[NSShadow alloc] init] autorelease]; [dropShadow setShadowColor:[NSColor blackColor]]; [dropShadow setShadowBlurRadius:5];

NSTextView does not scroll when created with NSCollectionView

旧时模样 提交于 2019-12-08 03:30:28
问题 I have an NSTextView that is on a view that is the view of an NSCollectionViewItem. I give the user the option to hide the NSTextView and instead bring up an NSView object in its place on the same view. However, when I run the program with the NSView object hidden and overlapping the NSTextView, scrolling in the NSTextView does not work correctly; The vertical scroll bar is there and adjusts its size accordingly to the size of the content in the NSTextView. However, the actual scrolling only

How do I fix the height of my view after collapsing NSSplitView?

こ雲淡風輕ζ 提交于 2019-12-08 02:48:09
问题 I've got an NSSplitView with an NSScrollView in the bottom view. The problem is when I collapse, and then re-open (un-collapse) the bottom view, the height of the scroll view is beyond the height of that bottom view so the top part of the scoll view is being clipped. I've got my scroll view and my split view set to autoresize in all directions in IB. Do I need to adjust the height of that scroll view after the un-collapse or am I setting a resizing property wrong, or something else? Below is