Questions tagged [catransaction]

CATransaction allows you to make batch updates to the Core Animation render tree, and it also allows to trigger implicit animations just by setting layer properties inside of a CATransaction.

CATransaction allows you to make batch updates to the Core Animation render tree. It is most used to override default animation timing functions, durations, etc. or to add a completion block to an animation that doesn't expose one explicitly.

CATransaction allows to trigger implicit animations just by setting layer properties inside of a transaction block. Animating the position of a layer in Objective C:

[CATransaction begin];
[CATransaction setAnimationDuration:0.5];
layer.position = newPosition;
[CATransaction commit];

or the same in Swift:

CATransaction.begin()
CATransaction.setAnimationDuration(0.5)
layer.position = newPosition
CATransaction.commit()

For more information, see the Apple Documentation for CATransaction.

73 questions
1
vote
0 answers

Swift CATransaction objecting moving instantly not following duration

I am converting an Objective C app to Swift and come across an issue. Here is my Objective C code which works. [CATransaction begin]; [CATransaction setAnimationDuration:seconds]; [CATransaction setAnimationTimingFunction:[CAMediaTimingFunction…
Breathable
  • 81
  • 9
1
vote
1 answer

Flickering in CABasicAnimation for rotation

I am trying to rotate a CAShapeLayer by an angle from its current angle whenever a button is pressed. I am using delegate function animationDidStop to set the transform of the layer during end of animation, since I have noticed animation only…
1
vote
0 answers

Animate UIView with Anchor Point and stretchable image

I'm trying to animate a bar chart where the images rise from the bottom. After a few hours, I'm seeing this is not an easy thing to achieve. I simply want to do one thing: Create an animation that scales up from a bottom center anchor point. -…
Buyin Brian
  • 2,626
  • 2
  • 24
  • 42
1
vote
0 answers

What are some of the use cases of explicitly creating a CATransaction?

Core Animation docs state that: "One of the main reasons to use transactions is that within the confines of an explicit transaction, you can change the duration, timing function, and other parameters." This is something doable with an explicit…
Evil Nodoer
  • 1,817
  • 2
  • 21
  • 31
1
vote
0 answers

Changing duration of UIviewController transition

I am using this code to change between one view controller to another: UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle: nil]; UIViewController *lvc = [storyboard…
Alessandro
  • 3,859
  • 11
  • 58
  • 124
1
vote
1 answer

CATransaction CompletionBlock Firing Immediately

I have this piece of code that works perfectly in one of my other projects where I am achieving a 'strobe' effect of text flashing from black to white on a loop. When I copied and pasted it into another one of my projects, the CompletionBlock fires…
Kevin_TA
  • 4,227
  • 10
  • 42
  • 71
0
votes
2 answers

What's the difference between CATransaction and CAAnimation?

maybe duplicated with some question, but I can't find them here.
CarmeloS
  • 7,478
  • 5
  • 51
  • 98
0
votes
1 answer

Swift - Movement of GMSMarker along array of CLCoordinates from GMSPath (Google Maps SDK for iOS)

All attempts at animating marker movement in Google Maps between coordinates point to using the following snippet of code in Swift: CATransaction.begin() CATransaction.setAnimationDuration(duration) marker.position =…
Michael James
  • 350
  • 4
  • 15
0
votes
1 answer

iOS Core-Animation: Performance issues with CATransaction / Interpolating transform matrices

I am performance testing my iPhone app: // using CATransaction like this goes from 14fps to 19fps [CATransaction begin]; [CATransaction setDisableActions: YES]; // NEG, as coord system is flipped/messed up self.transform =…
P i
  • 25,182
  • 33
  • 133
  • 229
0
votes
1 answer

CATransaction : How to Cancel?

I have following transaction on a CALayer: CATransaction.begin() CATransaction.setAnimationDuration(2) self.myLayer.opacity = 1 CATransaction.commit() Since the transaction goes on for two seconds, there are moments where I have to cancel/pause. …
Gizmodo
  • 2,563
  • 4
  • 32
  • 71
0
votes
1 answer

Why is UIView animation not working when starting right after view is added?

The animation of a UIView should start right after the view is added to the superview: class myView: UIView { override func didMoveToSuperview() { super.didMoveToSuperview() UIView.animate( withDuration: duration, …
Manuel
  • 11,849
  • 3
  • 39
  • 93
0
votes
2 answers

CALayer - animating layer size blocks animation from running

I have a method in which a bunch of layers are positioned, and a single "activated" layer (basically a layer that the user has clicked on) is both positioned and resized at the same time. All the layers, including the activated layer are sublayers…
indragie
  • 17,634
  • 15
  • 89
  • 161
0
votes
1 answer

CAShapeLayer Path Animation

I'm trying to animate a path change on a particular shape. I can manually change without animation by replacing this code with a simple .path [cgpath] setter. However, I want to animate the change for aesthetics. When this code executes, there is…
0
votes
2 answers

Swift 3 How to correctly write Completion Handler Block

I am new to Xcode and programming languages and I need your help. I am working on a Message application and I'm unable to use a Completion Handler Block. Here is my code : @IBAction func SendButton(_ sender: AnyObject) { if…
0
votes
1 answer

Behave of nested CATransaction?

The code below will update the backgroundColor immediately after the commit. [CATransaction begin]; self.view.backgroundColor = [UIColor redColor]; [CATransaction commit]; sleep(5); But with nested explicit CATransactions, screen update only when…
Karl
  • 605
  • 4
  • 13