Move a NSButton from one point to another with CATransaction but after that i can't click on it

StackOverflow https://stackoverflow.com/questions/10468330

  •  06-06-2021
  •  | 
  •  

Question

I use below code for move a NSButton with animation from one point to another but after i do it i can't access button,means i can't click on it (it's disabled)

[CATransaction begin];
    [CATransaction setValue:[NSNumber numberWithFloat:1.0] forKey:kCATransactionAnimationDuration];
    btn.layer.frame=CGRectMake(200, 100, 48,48);
    [CATransaction commit];
Was it helpful?

Solution

Is there a reason that you're using CATransaction to do this move? You can change the buttons frame with this one line, and everything works fine:

[btn.animator setFrame:NSMakeRect(200, 100, 48,48)];

(I don't have any experience with CATransaction, so I can't say why that's not working)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top