core-animation

Soft scroll animation NSScrollView scrollToPoint:

坚强是说给别人听的谎言 提交于 2019-12-04 01:04:23
I want to create soft animation between transitions in simply UI: view that moved When a call scrollToPoint: for move view to point that transition doesn't animate. I'm newbe in Cocoa programming (iOS is my background). And I don't know how right use .animator or NSAnimationContext. Also I was read Core Animation guide but didn't find the solution. The source can be reach on Git Hub repository Please help !!! scrollToPoint is not animatable. Only animatable properties like bounds and position in NSAnimatablePropertyContainer are animated. You don't need to do anything with CALayer: remove the

CALayer delegate method drawLayer not getting called

99封情书 提交于 2019-12-04 00:02:41
My object a sub class of NSObject has CALayer instance variable. I use it for drawing and caching content with its delegate set to my object. But for some reason drawLayer:inContext: method NEVER gets called. Whereas actionForLayer:forKey: delegate method does get called implying the delegate is getting set properly with layer.delegate = self in the object's init method. Any suggestions on what is preventing my layer drawing method drawLayer:inContext: from getting called ? I am called the [layer setNeedDisplay] often. So I guess it is some fundamental error. drawLayer:inContext: won't get

Why does a CAShapeLayer's stroke extend out of the frame?

我怕爱的太早我们不能终老 提交于 2019-12-03 23:23:52
Here's sample code: //Called by VC: HICircleView *circleView = [[HICircleView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; // init of circle view - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { CAShapeLayer *borderLayer = [CAShapeLayer layer]; borderLayer.fillColor = [UIColor whiteColor].CGColor; borderLayer.path = [UIBezierPath bezierPathWithOvalInRect:self.frame].CGPath; borderLayer.strokeColor = [[UIColor redColor] CGColor]; borderLayer.lineWidth = 5; [self.layer addSublayer:borderLayer]; } return self; } OK, thanks for the answer. to shift i: CGRect

How to use CoreAnimation to animate a circle like a clock countdown

天涯浪子 提交于 2019-12-03 23:19:48
问题 I wish to have a time countdown indicator just like a circle to start from a slice of arch to a full circle. I have tried several ways, both ended up with the arch turning directly to be a full circle, not go clockwise. Shown in demo pics as following: Any idea? Greatly appreciated! 回答1: SetNeedsDisplay when you change one of the angles, you can do some optimizations to only redraw the affected area. Put something like this into your draw function of your view. Good Luck CGContextRef

CAGradientLayer showing as solid color

怎甘沉沦 提交于 2019-12-03 21:45:24
I'm trying to set a gradient background on a view, but my code below makes the UIView appear solid black. If i change the whiteColor to greenColor, the gradient is displayed properly. Changing the backgroundColor of the layer to greenColor makes the view appear solid green. My guess is that i'm dealing with some kind of transparency-issue, but i can't figure to work around it. CAGradientLayer *gradientLayer = [CAGradientLayer layer]; gradientLayer.colors = [NSArray arrayWithObjects: (id)[[UIColor whiteColor] CGColor], (id)[[UIColor blackColor] CGColor], nil]; gradientLayer.frame = CGRectMake(0

Changing speed of an ongoing CAKeyframeAnimation animation

本秂侑毒 提交于 2019-12-03 20:26:24
I added an CAKeyframeAnimation with the Key "SpeedBoat" to a CALayer. Now I am trying to change the speed of the animation during the animation. [[self.shipLayer animationForKey:@"SpeedBoat"] setSpeed:([[self.shipLayer animationForKey:@"SpeedBoat"] speed] + deltaTime)]; There seems to be an error in this line. But I do not get any debug informations. What is wrong here? Is it possible to change the speed of an ongoing animation? It would be very nice if somebody could help me :) Best regards xen Max MacLeod Yes, you can definitely change the speed of an animation. That's because

Best way to implement animation on iPhone SDK?

只谈情不闲聊 提交于 2019-12-03 20:18:56
I know how to implement the basic animation by moving/resizing a UIView. However, the following two animations seems a bit complicated. 1) Imagine a car game, where when you press on the pedal button the speedometer spins. How to do the kind of animation where the bar "fills up" in a circular shape? 2) The second animation is easier to describe. How to do the animation of numbers increasing where the number slides down and the new number appears from the top similar to a slot machine. For your first question, I would think that CGAffineTransform would be the way to go. Using this, I would

How do you flip non-fullscreen UIView's in a superview with rounded corners?

浪尽此生 提交于 2019-12-03 20:16:49
I'm flipping UIViews similar to the page flip of the Weather app. The views are not fullscreen, though, and the superview has rounded corners. The problem is that during the flip animation the rounded corners of the superview are filled out to the square corners with black. Here's how I'm setting the corners: self.view.layer.cornerRadius = 15.0f; self.view.clipsToBounds = YES; Here's how I'm flipping the views (both frontView and backView are retained): UIView *toView; UIView *fromView; UIViewAnimationOptions animationType; if (toFront) { toView = self.frontView; fromView = self.backView;

How to flip a UIView around the x-axis while simultaneously switching subviews

巧了我就是萌 提交于 2019-12-03 19:31:23
问题 This question has been asked before but in a slightly different way and I was unable to get any of the answers to work the way I wanted, so I am hoping somebody with great Core Animation skills can help me out. I have a set of cards on a table. As the user swipes up or down the set of cards move up and down the table. There are 4 cards visible on the screen at any given time, but only the second card is showing its face. As the user swipes the second card flips back onto its face and the next

Grouping two Core Animations with CAAnimationGroup causes one CABasicAnimation to not run

余生颓废 提交于 2019-12-03 18:51:56
问题 I have two animations that I'm trying to perform on a UILabel on the iPhone with OS 3.1.2. The first rocks the UILabel back and forth: CAKeyframeAnimation *rock; rock = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"]; [rock setBeginTime:0.0f]; [rock setDuration:5.0]; [rock setRepeatCount:10000]; NSMutableArray *values = [NSMutableArray array]; MovingMath *math = [[MovingMath alloc] init]; // Center start position [values addObject:[math DegreesToNumber:0]]; // Turn right