Property layer not found on object of type UIBarButtonitem

I am trying to apply this animation to a UIBarButtonItem:

CABasicAnimation *theAnimation; theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"]; theAnimation.duration=1.0; theAnimation.repeatCount=HUGE_VALF; theAnimation.autoreverses=YES; theAnimation.fromValue=[NSNumber numberWithFloat:1.0]; theAnimation.toValue=[NSNumber numberWithFloat:0.5]; [plusbutton.layer addAnimation:theAnimation forKey:@"animateOpacity"]; 

but I get an error in the header of the last line of code. How can I access the barbuttonItem layer?

+4
source share
2 answers

The panel button element is not a view, and it does not have a layer.

Assuming you're not trying to do this on a system element, instead go to the customView element customView .

+6
source

You need to bind the QuartCore structure and import QuartzCore / QuartzCore.h into your class for working with layers.

0
source

Source: https://habr.com/ru/post/1468783/


All Articles