core-animation

Animate UIImage in UIImageView Up & Down (Like it's hovering) Loop

社会主义新天地 提交于 2019-12-03 10:37:14
问题 Hello I have an image that I'd like to move up and down (Up 10 pixels and down 10 pixels) so that my image appears to be hovering. How can I do this with simple animation thanks so much!!! 回答1: You could use Core Animation to animate the position of the views layer. If you configure the animation to be additive you won't have to bother calculating the new absolute position, just the change (relative position). CABasicAnimation *hover = [CABasicAnimation animationWithKeyPath:@"position"];

Core Animation Image sequence

ぃ、小莉子 提交于 2019-12-03 10:16:49
问题 How would i go about creating an image sequence with core animation. I would like to: add image1 for 1 second then remove image add image2 for 2 seconds then remove image add image1 for 3 seconds then remove CGImageRef image1 = [self getImage1]; CALayer *image1Layer = [CALayer layer]; image1Layer.bounds = CGRectMake(0, 0, 480, 320); image1Layer.position = CGPointMake(0, 0); image1Layer.contents = (id)image1; CABasicAnimation *animation1 = [CABasicAnimation animationWithKeyPath:@"animation"];

Switching CABasicAnimation on the position property mid animation causes a flicker

瘦欲@ 提交于 2019-12-03 10:14:50
问题 I have some code that uses CALayers to have bubbles flowing bottom to top. If the user touches the screen I have some code that replaces the currently running animation with one that has a toPoint where the finger touched down. When the animation switches it causes a flicker on the device (not on the simulator). Any tips on eliminating the flicker would be appreciated! Thanks. Code for the bubbles flowing up inside the layer itself: CABasicAnimation *animation =

CAKeyframeAnimation Manual Progress

我是研究僧i 提交于 2019-12-03 10:12:32
问题 I have a UIView whose backing layer has a CAKeyframeAnimation with a simple straight line path set as its `path`. Can I have the animation "frozen", so to speak, and manually change its progress? For example: If the path is 100 points in length, setting the progress (offset?) to 0.45 should have the view move 45 points down the path. I remember seeing an article that did something similar (moving a view along a path based on the value from a slider) via CAMediaTiming interfaces, but I haven't

CALayer: Single pixel line looks like 2 pixels

∥☆過路亽.° 提交于 2019-12-03 09:57:13
问题 This is my code: int columns 3; int columnWidth = self.layer.bounds.size.width / 3; for (int c = 1; c < columns; c++) { CALayer *layer = [CALayer layer]; layer.frame = (CGRectMake(columnWidth * c + 0.5, 0.5, 1, self.layer.bounds.size.height)); layer.backgroundColor = myColor; [grid addSublayer:layer]; } I understand that I have to shift the x and y 0.5 pixels, which is what I have done, yet it still shows as a 2 pixel line instead of 1. 回答1: Set the layer Frame as layer.frame = (CGRectMake

Change animation time for properties of a CALayer

霸气de小男生 提交于 2019-12-03 09:51:32
问题 I have a CALayer to animate a change in its image contents. Now, how can I change how long it takes for this animation to take place? 回答1: It's more or less simple. You have an ivar CALayer *yourLayer . Then you set the delegate and implement the delegate method -(id<CAAction>)actionForLayer:forKey: - (void)awakeFromNib { yourLayer.delegate = self; yourLayer.name = @"yourLayer"; } - (id <CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event { if([layer.name isEqualToString

CATransition push without fade

风流意气都作罢 提交于 2019-12-03 09:45:24
问题 I'm making a navigation controller class for Mac OS X. I want to replace the current view with a kCATransitionPush animation. Like in this post: Core Animation Tutorial - Wizard Dialog With Transitions The CATransition is set up like this: CATransition *transition = [CATransition animation]; transition.type = kCATransitionPush; transition.subtype = kCATransitionFromLeft; [self.view setAnimations:@{ @"subviews" : transition }]; However, when I replace the views, there is a fade animation,

Fill UIImageView with other color animated

回眸只為那壹抹淺笑 提交于 2019-12-03 09:31:21
I'm having a imageview and I want that imageview to animate with a color. So my image is first a green one and then I want to animate it to a orange one. This is my code: class TestView: UIView { func startAnimate(){ let size:CGSize = self.bounds.size let layer = UIImageView(image: UIImage(named: "LaunchIcon")) layer.frame = self.bounds let initialRect:CGRect = CGRect.init(x: 0, y: size.height, width: size.width, height: 0) let finalRect:CGRect = CGRect.init(x: 0, y: size.height, width: size.width, height: size.height) let sublayer = CALayer() sublayer.frame = initialRect sublayer

Creating a movie file of a animation with avassetwriter

自作多情 提交于 2019-12-03 09:29:32
I have a animation created using normal core animation methods. If there any way to create a movie file using avassetwriter? Ive seen other questions which show the how to use avassetwriter to create a movie using images, but i would like to create a movie using a animation created with core animation. Thank in advance invalidname Run a timer (or whatever) to periodically convert the animation's CALayer to a UIImage (see here ), then write that image to the AVAssetWriter as seen in the other examples you cite. You'll also need to keep track of elapsed time, because ultimately what you're

How do you override UIView's +(id)layer; class method?

半城伤御伤魂 提交于 2019-12-03 09:03:16
I read in the documentation that a UIView's 'layer' property is read only and that you must override UIView's + (id)layer; class method to access the layer's styling properties. Are there any examples of overriding this method to return a layer/view with styling properties already applied? If you just want to set properties like backgroundColor, opacity, etc. on the default CALayer that's assigned to the UIView, you can set those on the UIView's layer at any time using something like the following: view.layer.opacity = 0.0f; The only time that you would need to override the - (CALayer)layer