OGeek|极客世界-中国程序员成长平台

标题: ios - 如何在ios中的CALayer上添加按钮? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 01:49
标题: ios - 如何在ios中的CALayer上添加按钮?

如何在 CALayer 上添加 UIButtons , UILabels UIImageView 并根据按下的按钮执行 Action 。谢谢提前

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

我使用了上面的代码,但是当我按下按钮时它没有执行任何操作 谢谢



Best Answer-推荐答案


CALayer 不是事件响应者,如果您想要一个实际在 CALayer 之上工作的按钮,请将 CALayer 放入 UIView 并将 UIButton 添加到该 View 。

关于ios - 如何在ios中的CALayer上添加按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25820756/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4