core-animation

Animating images using CAAnimation

≡放荡痞女 提交于 2019-12-03 08:59:11
Is it possible to implement animating sequence of images using CAAnimation? And i dont want to use UIImageView... I need Something similar to UIImageView where we can set imageView.animationImages and calling startAnimation... but using CAAnimation CAKeyframeAnimation *animationSequence = [CAKeyframeAnimation animationWithKeyPath: @"contents"]; animationSequence.calculationMode = kCAAnimationLinear; animationSequence.autoreverses = YES; animationSequence.duration = kDefaultAnimationDuration; animationSequence.repeatCount = HUGE_VALF; NSMutableArray *animationSequenceArray = [[NSMutableArray

On iOS, setNeedsDisplay really doesn't cause drawRect to be called… unless CALayer's display or drawInContext finally calls drawRect?

六眼飞鱼酱① 提交于 2019-12-03 08:51:47
I don't really understand how CALayer's display and drawInContext relate to drawRect in the view. If I have an NSTimer that sets the [self.view setNeedsDisplay] every 1 second, then drawRect is called every 1 second, as shown by an NSLog statement inside of drawRect . But if I subclass a CALayer and use that for the view, if I make the display method empty, then now drawRect is never called. Update: But display is called every 1 second, as shown by an NSLog statement. If I remove that empty display method and add an empty drawInContext method, again, drawRect is never called. Update: But

animating the length of circular arrow mask in Core Animation

无人久伴 提交于 2019-12-03 08:51:23
问题 I've created a circular animation using CAShapeLayer and masking. Here is my code: - (void) maskAnimation{ animationCompletionBlock theBlock; imageView.hidden = FALSE;//Show the image view CAShapeLayer *maskLayer = [CAShapeLayer layer]; CGFloat maskHeight = imageView.layer.bounds.size.height; CGFloat maskWidth = imageView.layer.bounds.size.width; CGPoint centerPoint; centerPoint = CGPointMake( maskWidth/2, maskHeight/2); //Make the radius of our arc large enough to reach into the corners of

Core Animation 'flip' animation

允我心安 提交于 2019-12-03 08:47:52
I'm looking to use Core Animation to simulate a flip clock animation in a Mac application. Currently I have three CALayer's representing the top and bottom half of the digit, and a third used to represent the flip animation (a solution found in the follow article: Creating an iPad flip-clock with Core Animation . The animation of the flip layer is broken into two stages: flipping from the top to the middle of the digit, and then from the middle to the bottom. To achieve this, I use a delegate function which is called whenever an animation ends: - (void)animationDidStop:(CAAnimation *

Doing completely custom animations with Core Animation - performance

*爱你&永不变心* 提交于 2019-12-03 08:43:52
The article https://www.objc.io/issues/12-animations/animating-custom-layer-properties/ has this to say about doing completely custom animations with Core Animation: Suppose that instead of implementing our clock face using individual layers, we wanted to draw the clock using Core Graphics. (In general this will have inferior performance , but it’s possible to imagine that there are complex drawing operations that we might want to implement that would be hard to replicate using ordinary layer properties and transforms.) How would we do that? In other words, we draw each frame of the CA

CAShapeLayer used in UIView subclass doesn't work

China☆狼群 提交于 2019-12-03 08:15:50
i tried a few hours to get a dotted border around my UIView with CAShapeLayer but i don't get it displayed. ScaleOverlay.h #import <UIKit/UIKit.h> #import <QuartzCore/QuartzCore.h> @interface ScaleOverlay : UIView <UIGestureRecognizerDelegate> { CAShapeLayer *shapeLayer_; } @end ScaleOverlay.m - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor redColor]; self.alpha = 0; //Round corners [[self layer] setCornerRadius:8.f]; [[self layer] setMasksToBounds:YES]; //Border shapeLayer_ = [[CAShapeLayer layer] retain]; CGMutablePathRef

Is there a way to prevent CALayer shadows from overlapping adjacent layers?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 08:10:25
I have a collection of CALayers . Each layer is a sublayer of the same parent CALayer , and each has a shadow applied to it. The layers are positioned dynamically, and there are many of them, so I can't predict how they'll be arranged ahead of time. If the layers are adjacent to each other (close enough that they are almost touching) the shadow of one of the CALayers is rendered on top of the other CALayer . That's probably the desired effect in most cases, but I want my layers to exist in the same z-plane. (An example of this is the way CSS3 shadows are applied to block elements in web design

Is there an way to pause an Core Animation and resume it at some time later?

微笑、不失礼 提交于 2019-12-03 08:02:37
I have several Core Animation's going on at the same time. They all have an context and an animation id, where the context is the object that's beeing animated (UIImageView objects). I would like to pause them, so that the animation just stops temporarily, and then when some things are done, resume it to complete it. These things happen only on very fast scroll movements in an UIScrollView. I want to improve performance by stopping all ongoing animations but not the one that makes the scroll view scroll. I have implemented an custom animation of the contentOffset for that scroll view. Douglas

Flip, Grow, and Translate Animation

别说谁变了你拦得住时间么 提交于 2019-12-03 07:42:37
问题 Look at this video of the MLB At Bat app. Basically, I just want to present a modalViewController with the UIModalPresentationFormSheet style and have it grow from another view then flip. Like when you tap on a game in the scoreboard on the MLB app. Anyone know how I can accomplish this? Thanks EDIT: My main view is pretty much the same setup as the MLB app. I'm using AQGridView and want the animation to occur when a cell in the grid view is tapped. EDIT 2: I'd also be open to ditching the

How to adjust drop shadow dynamically during an UIImageView rotation?

China☆狼群 提交于 2019-12-03 06:59:37
I use the following to code to add drop shadow: letterE.layer.shadowColor = [[UIColor blackColor] CGColor]; letterE.layer.shadowOffset = CGSizeMake(2.5, 2.5); letterE.layer.shadowRadius = 3.0; letterE.layer.shadowOpacity = 0.95; and the following to rotate: CABasicAnimation* rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0]; rotationAnimation.duration = 5.0; rotationAnimation.cumulative = YES; rotationAnimation.repeatCount = 1.0; rotationAnimation.timingFunction =