nsview

PaintCode NSButton displays upside-down

前提是你 提交于 2019-12-24 12:28:38
问题 I am using PaintCode to create a button. I import the StyleKit, and create the NSButton Class for my RankView button. Like this: import Cocoa @IBDesignable class RankView: NSButton { override func drawRect(dirtyRect: NSRect) { super.drawRect(dirtyRect) StyleKit.drawRank2() // Drawing code here. } } But when I run the app, (and even in the storyboard), the button is upside-down. Like this: The arrow should be Up, but it points down. Whenever I change the parent class to NSView it displays

CALayer and drawRect

£可爱£侵袭症+ 提交于 2019-12-24 10:27:42
问题 I'm completely new to Core Animation, CALayer and all this stuff, so bear with me. I have a custom NSTextField using as a Label. I would want the content to animate it's position, so the whole string get's visible if it's too long for the Labels width. Now, the animation itself is working fine. I've implemented this with CABasicAnimation: - (void)awakeFromNib { CALayer *newLayer = [CALayer layer]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; [animation

Can I redraw a custom NSView while another control on the same window is being used?

梦想与她 提交于 2019-12-24 07:06:21
问题 In a program I am working on I am performing a large amount of data crunching, and want to be able draw a custom NSView to represent the process visually. The data crunching is processed off the main thread by using GCD (using dispatch_sync as the order needs to be preserved): for (int i=0; i<iterations; i++) { dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // Add a data crunching task to the queue! }); } When the processing is started I initialise a timer,

Is it possible to print IKImageBrowserView In Cocoa programmatically?

谁说我不能喝 提交于 2019-12-24 04:06:33
问题 I want to take print of IKImageBrowserView with (content) images. I tried the following code if (code == NSOKButton) { NSPrintInfo *printInfo; NSPrintInfo *sharedInfo; NSPrintOperation *printOp; NSMutableDictionary *printInfoDict; NSMutableDictionary *sharedDict; sharedInfo = [NSPrintInfo sharedPrintInfo]; sharedDict = [sharedInfo dictionary]; printInfoDict = [NSMutableDictionary dictionaryWithDictionary: sharedDict]; [printInfoDict setObject:NSPrintSaveJob forKey:NSPrintJobDisposition];

NSPopover in NSCollectionView (or not)

强颜欢笑 提交于 2019-12-24 02:55:14
问题 I have a custom subclass of NSView that is used in an NSCollectionView . The view shows a NSPopover when it is double clicked using the code below: - (void)mouseDown:(NSEvent *)theEvent { [super mouseDown:theEvent]; if ([theEvent clickCount] == 2) { [popover showRelativeToRect:[self bounds] ofView:self preferredEdge:NSMaxYEdge]; } } popover is an IBOutlet (yes it's connected). This works fine when the view is placed in a window normally, but when the view is in the collection view, it doesn't

How to change Corner Radius of NSView in Swift Language

限于喜欢 提交于 2019-12-24 02:31:51
问题 changing corner radius of NSView should be pretty straight forward however i am getting error message "fatal error: Can't unwrap Optional.None". is there a chance i am doing this with 10.9 not 10.10 and this is happening due framework differences? or the code is wrong. class aRoundView: NSView { let cornerRad = 5.0 init(frame: NSRect) { super.init(frame: frame) self.layer.cornerRadius = cornerRad } override func drawRect(dirtyRect: NSRect) { super.drawRect(dirtyRect) NSColor.redColor()

Change NSView background color when window has focus

ε祈祈猫儿з 提交于 2019-12-24 00:39:51
问题 I have noticed when an apps window contains an Outline view (such as XCode) it changes color when that window is in focus. With XCode for example, if the window is current then the outline view has a blueish background, if it looses focus it goes grey, Can anyone help me to replicate this? I presume its something to do with drawRect: but can only manage to get the color to change when the window loads. Maybe its a built in function and I'm just missing something? 回答1: All you have to do in

Obtain a CGContextRef of NSView outside of drawRect?

て烟熏妆下的殇ゞ 提交于 2019-12-23 09:38:49
问题 I need to get CGContextRef of NSView object. It won't be so bad if I knew how. In Carbon this thing was done like this: CGContextRef cgref = (libvlc_drawable_t)GetWindowPort(HIViewGetWindow((OpaqueControlRef*)hiViewRef)); Obviously it can be done by subclassing NSView (or it's subclass) and catching it in it's drawRect, but that's too ugly. Your ideas? 回答1: I've never used it but it think this is your way: [myView lockFocus]; imageContext = (CGContextRef)[[NSGraphicsContext currentContext]

How to code drawing a straight line with two mouse clicks (OSX Mac App)?

泪湿孤枕 提交于 2019-12-23 05:02:26
问题 I'm trying to make a simple drawing app (OSX Mac app) and I'm trying to figure out how the user can draw a line by two mouse clicks, for example, the first mouse click (mouseDown then mouseUP) would mark the origin point of the line, and the second mouse click (mouseDown then mouseUP) would mark the end point of the line. Before the user makes the second click of the end point, I'd like the line (before anchoring the end point) to be shown live, kind of like in photoshop. Both Objective-C and

Scale NSView centered

China☆狼群 提交于 2019-12-23 03:08:03
问题 I need to scale an NSView around it's center. I tried using CATransform3DMakeScale and it worked to scale the view towards it's corner but I couldn't achieve to center it. I tried to set the layers anchor point to .5, .5 but that didn't work. I tried using scaleUnitSquareToSize but I ran into the problem that this seems unresetable without a lot of work. In the end I need to be able to set the scale of an NSView to something like 0.8 and have it zoom out around it's center and be able to set