core-animation

Move a UIImageView

跟風遠走 提交于 2019-12-20 10:56:21
问题 What is the best way to move an image along an array of dots? 回答1: My recommended approach would be to wrap the UIImage in a UIImageView and use a CAKeyframeAnimation to animate your UIImageView's layer along a path that passes through your three points: UIImage *image = [UIImage imageNamed:@"image.png"]; imageView = [[UIImageView alloc] initWithImage:image]; [mainView addSubview:imageView]; // Remember to remove the image view and release it when done with it CAKeyframeAnimation

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

别来无恙 提交于 2019-12-20 10:47:20
问题 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 .

iOS / Core-Animation: Performance tuning

眉间皱痕 提交于 2019-12-20 10:46:34
问题 I have my app running on my iPad. but it is performing very badly -- I am getting below 15fps. can anyone help me to optimise? It is basically a wheel (derived from UIView) containing 12 buttons (derived from UIControl). As the user spins it, the buttons dynamically expand and contract (e.g. the one at the 12 o'clock position should always be the biggest) So my wheel contains a: - (void) displayLinkIsCallingBack: (CADisplayLink *) dispLink { : // using CATransaction like this goes from 14fps

CATransaction: Layer Changes But Does Not Animate

独自空忆成欢 提交于 2019-12-20 09:49:29
问题 I'm trying to animate part of UI in an iPad app when the user taps a button. I have this code in my action method. It works in the sense that the UI changes how I expect but it does not animate the changes. It simply immediately changes. I must be missing something: - (IBAction)someAction:(id)sender { UIViewController *aViewController = <# Get an existing UIViewController #>; UIView *viewToAnimate = aViewController.view; CALayer *layerToAnimate = viewToAnimate.layer; [CATransaction begin];

What kind of value is keyTime in an CAKeyFrameAnimation?

会有一股神秘感。 提交于 2019-12-20 09:47:21
问题 For example I have this CAKeyFrameAnimation: CALayer* theLayer = myView.layer; CAKeyframeAnimation* animation; animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.duration = 1.6; //animation.cumulative = YES; animation.repeatCount = 1; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; animation.values = [NSArray arrayWithObjects: [NSNumber numberWithFloat:0.0 * M_PI], [NSNumber numberWithFloat:(15.0/180.0) * M_PI], [NSNumber

How do i rotate a CALayer around a diagonal line?

荒凉一梦 提交于 2019-12-20 09:05:37
问题 I'm trying to implement a flip animation to be used in board game like iPhone-application. The animation is supposed to look like a game piece that rotates and changes to the color of its back (kind of like an Reversi piece). I've managed to create an animation that flips the piece around its orthogonal axis, but when I try to flip it around a diagonal axis by changing the rotation around the z-axis the actual image also gets rotated (not surprisingly). Instead I would like to rotate the

adding bounce effect to appearance of UIImageView

喜夏-厌秋 提交于 2019-12-20 08:32:12
问题 How can I add a bounce effect when I am about to show an UIImageView as a subview? Do I have to use CoreAnimation to do this? My only guess right now is to use CAKeyframeAnimation, please let me know if there's a better way. Here's my current code: CABasicAnimation * theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"]; theAnimation.delegate = self; theAnimation.duration = 1.0; theAnimation.fromValue = [NSNumber numberWithFloat:notif.center.y]; theAnimation.toValue

Add text to Video for specific time in iOS

随声附和 提交于 2019-12-20 07:26:47
问题 I am creating a video based application where I have to select any video from local gallery and have to add a text using CATextLayer over the Video. For this I am using below code: - (void) createWatermark:(UIImage*)image video:(NSURL*)videoURL { if (videoURL == nil) return; AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:videoURL options:nil]; AVMutableComposition* mixComposition = [AVMutableComposition composition]; AVMutableCompositionTrack* compositionVideoTrack = [mixComposition

How do I achieve a clearly rendered rotated UILabel?

强颜欢笑 提交于 2019-12-20 05:43:06
问题 I am trying to display rotated text. The UILabel is added as a subview on a UIImageView. The UIImageView has a transform created via say CGAffineTransformMakeRotation(M_PI/4.0). The text of the UILabel renders fairly blurry cf. the title label (in the screenshot, the blue background 'What's ...'). Do you know how I can manage to make the rotated text render clearly? I've already tried using an integral-based frame (which matters little since it'll be rotated), a non-clear background color,

Pre-rendered Core Graphics animation doesn't animate smoothly & hogs memory

情到浓时终转凉″ 提交于 2019-12-20 04:24:06
问题 I am posting this question in response to one of the answers on my previous question here: Multiple CALayer masks causing performance issues So, now that I am attempting to go down the pre-rendered animation approach, I am still unable to get a smooth animation. Not only that, but when run on an actual device, the app crashes periodically due to memory issues. You can see the animation running here: http://cl.ly/e3Qu (It may not look so bad from the video, but focus on the edge of animation,