core-animation

NSScrollView: fade in a top-border like Messages.app

瘦欲@ 提交于 2020-01-03 01:48:41
问题 What I Want to Do: In Messages.app on OS 10.10, when you scroll the left-most pane (the list of conversations) upwards, a nice horizontal line fades in over about 0.5 seconds. When you scroll back down, the line fades back out. What I Have: I am trying to achieve this effect in my own app and I've gotten very close. I subclassed NSScrollView and have done the following: - (void) awakeFromNib { _topBorderLayer = [[CALayer alloc] init]; CGColorRef bgColor = CGColorCreateGenericGray(0.8, 1.0f);

CABasicAnimation creates empty default value copy of CALayer

谁说胖子不能爱 提交于 2020-01-03 00:58:46
问题 I have a custom CALayer that draws radial gradients. It works great except during animation. It seems that each iteration of CABasicAnimation creates a new copy of the CALayer subclass with empty, default values for the properties: In the screenshot above, you see that CABasicAnimation has created a new copy of the layer and is updating gradientOrigin but none of the other properties have come along for the ride. This has the result of not rendering anything during the animation. Here's a GIF

Font issue with layer backed NSTextView

旧时模样 提交于 2020-01-02 19:32:41
问题 I have a small problem with the nstextview , when I send [textView setWantsLayer:YES] , the font in the textView become blurred, anybody know why is it? [[textView enclosingScrollView] setDrawsBackground:NO]; [textView setDrawsBackground:NO]; [textView setWantsLayer:YES]` 回答1: The problem here is likely with aliasing the text because the background color is transparent, thus causing it to alias against a transparent background, which is going to look pretty bad. Generally, I've found that I

How can I draw and rotate an Arrow at an Orientation in 3D Space?

≡放荡痞女 提交于 2020-01-02 18:55:38
问题 I want to draw an image like the following in a certain orientation. Assume that the device lies flat on a table the image above shows how the arrow should be drawn. The angle between the device and the table is called alpha and it is zero in this case. The arrow points straight to a predefined location point. If you rotate the device on the table the arrow will point alway to the target direction just like a compass. I did the update of the image position with the following code in 2D space:

How to animate line-drawing in iPhone development?

£可爱£侵袭症+ 提交于 2020-01-02 11:08:29
问题 I have been searching around, but there seems no good answer for this simple question. So I am asking again: how to animate line-drawing in iphone dev? Basically what I want is something like this: @implementation MyUIView - (void) triggerLineDrawing: (CGPathRef) path { ... // animate line drawing here // and the line should disappear automatically after a few seconds } Can it be done? 回答1: You can't do it automatically, only bu hand. To do it manually you should do something like this:

CALayer vs. drawInRect: performance?

旧巷老猫 提交于 2020-01-02 07:54:29
问题 I'm trying to draw some shadows in a rect. The shadow image itself is about 1px * 26px. Here's two methods I've thought of for drawing the image in the view: //These methods are called in drawRect: /* Method 1 */ [self.upperShadow drawInRect:rectHigh]; //upperShadow is UIImage [self.lowerShadow drawInRect:rectLow]; /* Method 2 */ CALayer *shadowTop = [CALayer layer]; shadowTop.frame = rectHigh; shadowTop.contents = (__bridge id)topShadow; //topShadow is CGImage [self.layer addSublayer

How to interact with layer-backed views on the Mac

痞子三分冷 提交于 2020-01-02 06:06:07
问题 I am designing a user interface containing several labels and text fields. I would like to style the UI like this: setting a background pattern for the content view of my NSWindow adding a custom icon to the background in the upper left corner I solved the first problem by making the content view a layer-backed view as described in Apple's documentation of NSView: A layer-backed view is a view that is backed by a Core Animation layer. Any drawing done by the view is the cached in the backing

Core Animation and Anti Aliased Fonts on the Mac

可紊 提交于 2020-01-02 04:53:22
问题 I'm trying to create a view that is backed by a Core Animation layer. However, when I enable the layer, my labels start to look slightly jagged. I've attached a demonstration of difference: I know it is subtle, but it is driving me crazy (especially for smaller fonts). Any way I can get the Core Animation layer labels to be anti-aliased? 回答1: Nitpick: the Core Animation layer is anti-aliased, but at a lower quality – it doesn’t use sub-pixel anti-aliasing. The reason for this is that sub

How can I show a sequence of buttons highlighting?

為{幸葍}努か 提交于 2020-01-01 20:36:12
问题 Similar to the Simon games of old, I want to show the user a button sequence & then have them repeat it back. The place I'm stuck is showing the first button highlighted for, say, 500ms, waiting 100ms, showing the second highlighted for 500ms, waiting another 100ms, showing the 3rd & so on. From other Stackoverflower'ers I've gotten to this block: redButton.highlighted = YES; [UIView beginAnimations:@"" context:nil]; [UIView setAnimationStartDate:[NSDate dateWithTimeIntervalSinceNow:1]];

NSImage rotation in NSView is not working

情到浓时终转凉″ 提交于 2020-01-01 19:44:48
问题 I am trying to rotate an NSImage inside a NSView., First I will show you what I have done so far. Image : Header file #import <Foundation/Foundation.h> #import <QuartzCore/QuartzCore.h> @interface AppController : NSObject { CALayer *syncFirst; } @property (weak) IBOutlet NSView *nsview; - (IBAction)buttonClicked:(id)sender; - (CGImageRef) convertToCGImageFromNasImage:(NSImage *) image; @end Implementation file, only related methods - (void)awakeFromNib { NSImage *image = [NSImage imageNamed:@