user2776957
user2776957

Reputation: 25

how to add buttons on CALayer in ios?

How to add UIButtons , UILabels UIImageView on CALayer and perform actions according to the button pressed.Thanks in advance

 {
   [graphic addSublayer:self.firstButton.layer];
   [graphic addSublayer:self.mylabel.layer];
   [self.view.layer addSublayer:graphic];
 }

I used the above code but when I pressed the button it does not perform any action Thanks

Upvotes: 2

Views: 2907

Answers (1)

Noor
Noor

Reputation: 2067

A CALayer is not an event responder, If you want a button that actually works on top of a CALayer, put that CALayer into a UIView and add a UIButton to that view.

Upvotes: 1

Related Questions