core-animation

Fade in/out UIScrollView's content like Mobile Safari does in its tab

久未见 提交于 2019-12-03 01:56:55
问题 NOTE: I added my new solution at the UPDATE answer below. I try to recreate the effects we saw in Mobile Safari's tab on iPhone/iPod touch. Basically, it's a UIScrollView that holds 4 reusable UIView (acting like ring buffer), and scrolls horizontally. When scrolling, the UIView's opacity will fade in/out seamlessly with offset. Currently, I do all the dirty job in - (void)scrollViewDidScroll:(UIScrollView *)scrollView . Such as getting the contentOffset from UIScrollView, determine the

How do you make images wobble like on the iPhone home screen?

陌路散爱 提交于 2019-12-03 01:32:38
问题 I have many icons in my app and I would like to animate them in a manner similar to what happens when you try to delete applications from the iPhone's home screen. How can you do this? Additionally, is there a way to have the icons animate up onto the screen in a manner similar to what happens when you unlock the iPhone? 回答1: If you want to make your views, images, etc. wobble, like the home screen, you could do something like this: CGAffineTransform leftWobble = CGAffineTransformRotate

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

删除回忆录丶 提交于 2019-12-03 01:25:11
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!!! 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"]; hover.additive = YES; // fromValue and toValue will be relative instead of absolute values hover.fromValue =

Fade In Fade Out Animation

天大地大妈咪最大 提交于 2019-12-03 00:45:58
问题 Here is some code I struggle with for a while. If you start the fade in animation, the label text fades in. If I start the fade out animation the the label text fades out. When I start the startFade method, only fade out is shown. How can I wait for the fadeIn method to finish visually before starting the fadeOut method. -(IBAction)startFade:(id)sender{ [self fadeIn]; [self fadeOut]; } -(IBAction)fadeIn:(id)sender{ [self fadeIn]; } -(IBAction)fadeOut:(id)sender{ [self fadeOut]; } -(void)

Switching CABasicAnimation on the position property mid animation causes a flicker

岁酱吖の 提交于 2019-12-03 00:45:49
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 = [CABasicAnimationanimationWithKeyPath:@"position"]; [animation setDelegate:self]; CGPoint position = [self position]; NSValue

Core Animation Image sequence

↘锁芯ラ 提交于 2019-12-03 00:44:06
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"]; animation1.repeatCount = 0; animation1.duration = 2.0; animation1.removedOnCompletion = YES; // i would

CAKeyframeAnimation Manual Progress

荒凉一梦 提交于 2019-12-03 00:39:13
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 been able to find it, even after a few hours of searching. If I'm approaching this in a completely

On iOS, why does setting a layer's sublayerTransform turn itself to act like CATranformLayer?

◇◆丶佛笑我妖孽 提交于 2019-12-03 00:31:23
It is known that the zPosition of the layers only determines which layer cover up which layer. Whether it is a zPosition of 10 or 1000 won't affect its position. That is, unless if we use CATransformLayer to contain those layers , then the zPosition of those layers will affect the layers' position. However, the following code running in iOS 5.1.1 does make the zPosition alter the position of the layers... you can try it in a new Single View App, and add the following code to ViewController.m . If the zPosition of layer2 is changed from 88 to 188 , we can see that the layer moves accordingly.

CALayer: Single pixel line looks like 2 pixels

北慕城南 提交于 2019-12-03 00:28:40
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. Set the layer Frame as layer.frame = (CGRectMake(columnWidth * c + 0.5, 0.5, 0.5, self.layer.bounds.size.height)); Yeah it will work for retina also Check this

Change animation time for properties of a CALayer

烈酒焚心 提交于 2019-12-03 00:21:13
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? papr 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 yourLayer.name]) { // Check for right layer CABasicAnimation *ani = [CABasicAnimation animationWithKeyPath