core-animation

CABasicAnimation not animating my property

狂风中的少年 提交于 2019-12-04 11:02:55
问题 I've been trying to understand what is wrong with my animation and I still haven't figure it out. I think it should be really straight forward, but there is probably something I'm missing, even after reading lot of examples and documentation. My problem comes originally form the fact that on the iPhone, you cannot resize layers automatically (with the view). The documentation says otherwise but there is no autoresizeMask for the layer in the SDKs. So I decided to make a little workaround and

Chain UIView animations with time intervals

依然范特西╮ 提交于 2019-12-04 10:44:26
问题 I need to animate 3 UIViews (fade in/out). 1 animation duration is 0.6s (fade in/out cycle is 0.6+0.6s). But I need to launch animations in 0.2 seconds. 1st animation should be launched in 0.0 seconds. 2nd animation should be launched in 0.2 seconds. 3rd animation should be launched in 0.4 seconds. And all of them should be looped "indefinitely" (until some trigger). What I have at the moment: - (void)playAnimation { isAnimated = YES; [self animateView:firstView afterDelay:0.0]; [self

How to make a CATransform3dMakeRotation rotate the other way? And chain together

流过昼夜 提交于 2019-12-04 10:43:34
I'm working with some Core Animation for the first time and in the process of implementing a playing card that I can flip around, I've decided to use a CALayer to display the contents (not sure how I'm going to get two sides, but that's another question) and I need to be able to flip it over, move it, etc... I'm using CATransaction with some success - in the snippet below, the card moves from the bottom left to the top left and flips over. The problem is that I wan't it to flip the opposite way, but don't know how to tell it, "hey, you're going the wrong way!" [CATransaction begin];

How to rotate an layer at a specific anchor point without a skip?

大憨熊 提交于 2019-12-04 10:30:52
问题 I want to rotate a layer with an image at the top left corner, and not the center. According to the docs I set the anchorPoint property to [0, 1]. The view rotates in my example by 50°, but before it starts to animate, the view jumps to another point at the screen. self.shakeTag.layer.anchorPoint = CGPointMake(0.0f, 1.0f); [UIView beginAnimations:@"rotate" context:nil]; [self.shakeTag.layer setTransform: CATransform3DRotate(CATransform3DIdentity, radians(50.0), 0.0f, 0.0f, 1.0f)]; [UIView

Drawing on top of UIImageView to make the image transparent

天涯浪子 提交于 2019-12-04 10:15:36
I am working on one iPhone App wherein I need to make a portion of the image transparent by setting its alpha level to 0 as the user moves around his finger on the image. Basically if you happen to know the app store application iSteam, user should be able to move his finger around on a top image which will make the background image transparent. Currently I am using two UIImageView. One that holds the background image and the other on top of it which holds a darker image. Now user should be able to draw random curves on this darker image which will make the part of the background image appear

CoreAnimation CALayer and CATextLayer combination

有些话、适合烂在心里 提交于 2019-12-04 10:06:27
I'am just playing around with CA lately. Now I am kind of stuck. This is the thing I want to animate: As for now I already got the circle animation working. I subclassed CALayer to make the animation. I really don't know where to go from here. Where do I have to add the sublayer of CATextLayer? How do I animate both at the same time so it looks like the text with its line is sticking at the circle end? If you need some code or anything else let me know. I would be really happy to get some help here :-) Thanks a lot! I was able to do what you are asking for below. Code is very rough, just spent

Fill UIImageView with other color animated

夙愿已清 提交于 2019-12-04 10:01:22
问题 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

Can I increase the animation speed of presentModalViewController?

别说谁变了你拦得住时间么 提交于 2019-12-04 09:59:47
I'm writing a drawing application that shows a tools view controller when the user clicks an item in a toolbar. However, several of my beta testers have reported that the tools palate opens too slowly. I'm using the standard presentModalViewController:animated: call to display the tools, and I've tried wrapping it in a code block like this to speed it up: [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration: 0.1]; [self presentModalViewController:settings animated:YES]; [UIView commitAnimations]; Unfortunately, that doesn't work. If you say animated:NO it works better, but

How to move a view along a curved path in iOS

泄露秘密 提交于 2019-12-04 09:15:37
问题 How to animate/move the view in the curve path, is it possible to do using UIAnimation. Like moving a view in the path as in the image. 回答1: You can do it using Core Animation and CAKeyFrameAnimation to define the curve points. See this tutorial: http://nachbaur.com/2011/01/07/core-animation-part-4/ 回答2: Above one can be achived by:- i)CAKeyframeAnimation ii)Create Curve Path iii)Animate layer of Custom View import UIKit import CoreGraphics class ViewController: UIViewController { var

How can I get a CAAnimation to call a block every animation tick?

跟風遠走 提交于 2019-12-04 08:58:31
Can I somehow have a block execute on every "tick" of a CAAnimation? It could possibly work like the code below. If there's a way to do this with a selector, that works too. NSString* keyPath = @"position.x"; CGFloat endValue = 100; [CATransaction setDisableActions:YES]; [self.layer setValue:@(toVal) forKeyPath:keyPath]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:keyPath]; animation.duration = 1; animation.delegate = self; __weak SelfClass* wself = self; animation.eachTick = ^{ NSLog(@"Current x value: %f", [wself valueForKeyPath:keypath]); }; [self.layer addAnimation