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.

76 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
  • 89
  • 10
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
1 answer

CATransaction: a view flashes on completion

I'm writing a little bit complex animation, which goes in 2 steps: Change opacity to 0 of UIViews that are not need to be visible and move a UIImageView (which has alpha = 1) to another CGPoint (position). Change opacity of another UIView to 1 and…
Randex
  • 770
  • 7
  • 30
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,781
  • 2
  • 28
  • 48
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,927
  • 3
  • 23
  • 32
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
  • 4,000
  • 12
  • 63
  • 131
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,575
  • 13
  • 48
  • 77
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,868
  • 8
  • 56
  • 103
0
votes
0 answers

"+[CATransaction synchronize] called within transaction" with NSSavePanel

Starting with macOS Ventura (or maybe with the latest Xcode version), I'm getting log messages in my Mac app: +[CATransaction synchronize] called within transaction whenever the app displays an NSSavePanel (or subclass). For instance: …
jeanlain
  • 382
  • 1
  • 3
  • 13
0
votes
1 answer

How to do linear transition and enlarge Animation By CAKeyframeAnimation?

I want to do a linear animation like this: move the rectangle slowly to center of Screen, and tripled its size while moving. Here is my wrong code and demo, I can only do animation one by one, but I want to combine this two animation. Also, the end…
0
votes
1 answer

How to animate the appearing of a CALayer using CATransaction?

I want to animate a CALAyer so that it looks like it appears out of nowhere. I thought I could first set the transform of the layer to "scale to x: 0, y: 0". Then do an animation to set the transform to "scale to x: 1, y: 1", which is the identity.…
Sweeper
  • 213,210
  • 22
  • 193
  • 313
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
  • 492
  • 1
  • 6
  • 19
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
  • 29,020
  • 36
  • 159
  • 267
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
  • 3,151
  • 7
  • 45
  • 92
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
  • 14,274
  • 6
  • 57
  • 130