i have a CALayer with core graphics in it and i typed some code to make it do something (anything) on the click of a button.
in the awakeFromNib method the layer (called graphicsLayer) is instantiated and made a child of another layer which is given to the NSView
the graphics layer is given bounds and frame so it shows up, and is given a delegate so i can draw on it with core graphics
now when the button is clicked this code is called:
this is by-the-book code and when it's triggered the layer's position is changed (according to the print statement) but on screen nothing happens...
am i missing something? i tried putting in
[graphicsLayer setNeedsDisplay];
after the changing of the position but no luck.
also i want to animate the stuff that's inside the layer, the core graphics itself... is that possible with core animation or do i need a timer to animate that stuff?
perhaps i'm animating the wrong thing? trying to animate opacity didn't work either
another thing
when i implement the mouseDown method in the NSView the position animates correctly as it should...
why doesn't the same code only work for the mouseDown method and not the method hooked up to the button?
in the awakeFromNib method the layer (called graphicsLayer) is instantiated and made a child of another layer which is given to the NSView
the graphics layer is given bounds and frame so it shows up, and is given a delegate so i can draw on it with core graphics
now when the button is clicked this code is called:
Code:
printf("%f %f\n", graphicsLayer.position.x, graphicsLayer.position.y);
graphicsLayer.position = CGPointMake(500, 20);
printf("%f %f\n", graphicsLayer.position.x, graphicsLayer.position.y);
this is by-the-book code and when it's triggered the layer's position is changed (according to the print statement) but on screen nothing happens...
am i missing something? i tried putting in
[graphicsLayer setNeedsDisplay];
after the changing of the position but no luck.
also i want to animate the stuff that's inside the layer, the core graphics itself... is that possible with core animation or do i need a timer to animate that stuff?
perhaps i'm animating the wrong thing? trying to animate opacity didn't work either
another thing
when i implement the mouseDown method in the NSView the position animates correctly as it should...
why doesn't the same code only work for the mouseDown method and not the method hooked up to the button?