core-animation

How can I create an CABasicAnimation for multiple properties?

杀马特。学长 韩版系。学妹 提交于 2019-12-17 21:47:01
问题 I have this code to animate a CALayer element. CABasicAnimation *makeBiggerAnim=[CABasicAnimation animationWithKeyPath:@"radius"]; makeBiggerAnim.duration=0.2; makeBiggerAnim.fromValue=[NSNumber numberWithDouble:20.0]; makeBiggerAnim.toValue=[NSNumber numberWithDouble:40.0]; makeBiggerAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; My question is, now everything works fine, I would like another attribute of the same element at the same time.

iOS animating UILabel expand

懵懂的女人 提交于 2019-12-17 18:56:51
问题 I have a UILabel that's initiated with 3 lines of text: locationDescription = [[UILabel alloc]init]; locationDescription.numberOfLines = 3; [locationDescription setTranslatesAutoresizingMaskIntoConstraints:NO]; [self addSubview:locationDescription]; I then have a button that expands the label: - (void)buttonPressed:(UIButton *)sender{ NSLog(@"Pressed"); [UIView animateWithDuration:1 animations:^{locationDescription.numberOfLines = 0;} ]; } The desired behavior for the label is to have each

How can I rotate a UIImageView with respect to any point (other than its center)?

断了今生、忘了曾经 提交于 2019-12-17 18:27:23
问题 By default, a UIImageView will rotate only about its center. How do I get it to rotate about any other point in the image? 回答1: One way of doing this is by changing the anchorPoint of the UIImageView's underlying layer and rotating about that. You can change the point of rotation using something like the following: imageView.layer.anchorPoint = CGPointMake(0.25, 0.25); anchorPoint is defined in terms of relative coordinates within the layer. That is, (0,0) is the upper-left of the layer (on

After Animation, View position resets

两盒软妹~` 提交于 2019-12-17 17:55:16
问题 I am trying to make a view slide from top to bottom. This is not a big deal, I used CABasicAnimation for this. The problem is when I want to remove the view. I use this animation. CABasicAnimation *animation; animation = [CABasicAnimation animationWithKeyPath:@"position"]; [animation setDelegate:self]; animation.toValue = [NSValue valueWithCGPoint:CGPointMake(self.view.layer.position.x, 0 - self.view.bounds.size.height / 2)]; animation.fromValue = [NSValue valueWithCGPoint:self.view.layer

How do I stack images to simulate depth using Core Animation?

偶尔善良 提交于 2019-12-17 17:52:43
问题 I have a series of UIImages with which I need to simulate depth. I can't use scaling because I need to be able to rotate the parent view, and the images should look like they're stacked visibly in front of each other, not on the same plane. I made a new ViewController-based project and put this in the viewDidLoad (as well as attached three 120x120 pixel images named 1.png, 2.png, and 3.png): - (void)viewDidLoad { // display image 3 UIImageView *three = [[UIImageView alloc] initWithImage:

how to implement an iPhone view transition animation with both flipping and scaling?

旧城冷巷雨未停 提交于 2019-12-17 17:52:42
问题 how can I implement the animation we see in the iPhone Music app's coverflow screen? when you click on a small view, it flips and scales up to another view? how can I do this? I can use core animation to flip and scale a view, but how can I do the transition to another view? thanks 回答1: You need an UIView as Container for the two UIView s (frontside/backside) and then remove/add these from/to the container as subviews while doing the animations in between: UIView *flipContainer; UIView

Basic keyframe animation (rotation)

跟風遠走 提交于 2019-12-17 17:38:52
问题 I'm trying to create a very simple keyframe animation, whereby a graphic Rotates from one angle to another, through a given midpoint. (The purpose is to be able to animate rotation through an OBTUSE angle of arc GREATER THAN 180 DEGREES, rather than having the animation 'cheat' and go the shortest route, i.e., via the opposite , ACUTE smaller angle -- which can happen when there's only one [i.e, destination] keyframe. To go the 'long' way around, I assume I need an extra keyframe midway

What causes this error? “CALayer position contains NaN: [240 nan]”

走远了吗. 提交于 2019-12-17 17:37:09
问题 I've seen this happen whenever i rotate a screen that has a UITableView on it. I've found out that it happens inbetween the willRotate and didRotate method calls in UIViewController My co-workers have seen it in other spots as well, usually around rotation. It hadnt started happening until very recently, and we're stumped as to how we should deal with it (google searches don't turn up the error message in its exact form). Has anyone else encountered this that knows what to do about it? 回答1:

How to animate the frame of an layer with CABasicAnimation?

℡╲_俬逩灬. 提交于 2019-12-17 15:44:37
问题 I guess I have to convert the CGRect into an object to pass it to fromValue? This is how I try it, but it doesn't work: CABasicAnimation *frameAnimation = [CABasicAnimation animationWithKeyPath:@"frame"]; frameAnimation.duration = 2.5; frameAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; frameAnimation.fromValue = [NSValue valueWithCGRect:myLayer.frame]; frameAnimation.toValue = [NSValue valueWithCGRect:theNewFrameRect]; [myLayer

How to animate CAShapeLayer path and fillColor

偶尔善良 提交于 2019-12-17 15:44:23
问题 How to animate CAShapeLayer path and fillColor? How to animate strokeEnd to show the path being drawn? and how to animate fillColor? 回答1: To animate path //setup the CAShapeLayer myShapeLayer.strokeColor = [[UIColor blueColor] CGColor]; myShapeLayer.lineWidth = 5; myShapeLayer.fillColor = [[UIColor yellowColor] CGColor]; //Display it! [self.view.layer addSublayer:myShapeLayer]; //Animate path CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; pathAnimation