core-animation

How do I prevent Core Animation blocking my main thread?

本小妞迷上赌 提交于 2019-12-19 10:26:36
问题 I'm aware of the fact that Core Animation dispatches its animations in a seperate thread, as stated in the documentation. Nevertheless, my animations seem to be blocking my main thread. All animations start and finnish. (With or without kCATransactionDisableActions set as true.) but become jumpy and the main runloop stalls. What am I doing wrong? Conceptual example: [NSTimer scheduledTimerWithTimeInterval:0.0333 target:self selector:@selector(gameEngine) userInfo:nil repeats:YES]; - (void

Change tabbarController's tab programmatically with animation

我与影子孤独终老i 提交于 2019-12-19 09:27:25
问题 I want to change tab through code with animation. Exact scenario is that there are 2 tabs with below hierarchy. First tab - Navigation controller - Login controller - Some other controller Second tab - Navigation controller - Screen with Logout button Now, if user presses logout, I need to display login screen. For that I need to switch tab to FirstTab and then popToRootViewController. So what I am doing is on logout button press I send NSNotification to LoginController which in turn executes

Get position of path at time

心已入冬 提交于 2019-12-19 08:00:53
问题 is there a nice way to calculate the position of a path (CGPath or UIBezierPath) at a given time (from 0 to 1)? Using CAShapeLayer for example, one can create an animated stroke end. I want to know the position of that stroke end at arbitrary times. Thanks in advance, Adrian 回答1: You can definitely base your approach on the CADisplayLink and a tracking layer. However, if you don't mind doing a little bit of math on your own, the solution is not too complicated. Plus, you wont have to depend

Is it possible to use Core Animation to fade out a UIBarButtonItem?

感情迁移 提交于 2019-12-19 07:56:35
问题 I'm curious, is it possible to somehow intertwine Core Animation to give a "fade out" of a UIBarButtonItem? I have a tableView which I represent with two different data sources. Once a particular data source gets triggered, I'd like to fade out the current UIToolBar options and fade in new ones. Thanks for pointing me in the right direction. 回答1: If you really are using a UIToolbar (note the lower-case "b") and not a UINavigationBar, there is a very easy way to change the buttons and have the

Animate CAShapeLayer path change

倖福魔咒の 提交于 2019-12-19 07:45:11
问题 I'm trying to animate change of path property of CAShapeLayer like this: animatePathChange(for: progressLayer, toPath: progressPath.cgPath) progressLayer.path = progressPath.cgPath And this is animatePathChange function code: func animatePathChange(for layer: CAShapeLayer, toPath: CGPath) { let animation = CABasicAnimation(keyPath: "path") animation.duration = 1.0 animation.fromValue = layer.path animation.toValue = toPath animation.timingFunction = CAMediaTimingFunction(name: "easeInEaseOut"

Animate a layer property which simply changes other properties?

半城伤御伤魂 提交于 2019-12-19 07:07:13
问题 Imagine a CAGradientLayer . It's very easy to animate .startPoint and .endPoint . Now imagine a float spinLike which simply sets both of them at once . {So, instead of having two different animations, you could simply animate spinLike .} So something like .. class CustomGradientLayer: CAGradientLayer { @objc var spinLike: CGFloat = 0 { didSet { startPoint = CGPoint( ... ) endPoint = CGPoint( ... ) setNeedsDisplay() } } } To animate spinLike ... class Test: UIView { ... g = CustomGradientLayer

Swift - Color fill animation

折月煮酒 提交于 2019-12-19 06:41:51
问题 I'm relatively new to ios animations and I believe there's something wrong with the approach I took to animate UIView. I will start with a UI screenshot to picture my problem more precisely: There is a tableView cell with two labels and colorful filled circle Anytime I introduce new value to the cell, I'd like to animate this left-most bulb so it looks like it's getting filled with red color. This is the implementation od BadgeView, which is basically the aforementioned leftmost filled circle

iOS CATransform3D Coordinates

强颜欢笑 提交于 2019-12-19 04:01:26
问题 Would really appreciate any help on this one. I have applied a 3D transformation on a view and need to identify the edge coordinates of the rendered view so I can present another view adjacent to it (without any pixels gap). Specifically I want a series of views ("pages") to fold-up like a leaflet, by animating the angle. int dir = (isOddNumberedPage ? 1 : -1); float angle = 10.0; theView.frame = CGRectMake(pageNumber * 320, 0, 320, 460); CATransform3D rotationAndPerspectiveTransform =

Can someone explain the CALayer contentsRect property's coordinate system to me?

空扰寡人 提交于 2019-12-19 03:11:49
问题 I realize that the contentsRect property of CALayer (documentation here) allows one to define how much of the layer to use for drawing, but I do not understand how the coordinate system works, I think. It seems that when the width/height are smaller, the area used for content is bigger and vice versa. Similarly, negative x,y positions seem to move the content area down and to the right which is the opposite of my intuition. Can someone explain why this is? I'm sure there is a good reason, but

Can someone explain the CALayer contentsRect property's coordinate system to me?

爷,独闯天下 提交于 2019-12-19 03:10:03
问题 I realize that the contentsRect property of CALayer (documentation here) allows one to define how much of the layer to use for drawing, but I do not understand how the coordinate system works, I think. It seems that when the width/height are smaller, the area used for content is bigger and vice versa. Similarly, negative x,y positions seem to move the content area down and to the right which is the opposite of my intuition. Can someone explain why this is? I'm sure there is a good reason, but