CAKeyframeAnimation与CABasicAnimation下的对象都不能接收touch事件,如果你想做点击的话,只能自己在self.view(即添加btn的父视图)上面做了,具体的,给self.view添加一个UITapGestureRecognizer,然后在里面去hitTest:-(void)click:(UITapGestureRecognizer *)gesture{
CGPoint touchPoint = [gesture locationInView:self.view];
if ([self.button.layer.presentationLayer hitTest:touchPoint]) {
self.view.backgroundColor = self.view.backgroundColor == [UIColor yellowColor] ? [UIColor redColor] : [UIColor yellowColor];
}
}
CGPoint touchPoint = [gesture locationInView:self.view];
if ([self.button.layer.presentationLayer hitTest:touchPoint]) {
self.view.backgroundColor = self.view.backgroundColor == [UIColor yellowColor] ? [UIColor redColor] : [UIColor yellowColor];
}
}
解决方案 »
- 用xcode编写一个可以读取PDF的程序
- push服务
- 用 PHP 和 XML 进行 iPhone 开发
- iphone 如何确认一个中文字符完成输入
- -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
- 方法间传值问题
- 各位前辈,请问用swift开发IOS应用也需要调用Object-C 的API 吗?谢谢!
- xmpp后台运行的问题,已解决,结贴
- worklight项目,google map api在ipad上崩溃,什么问题呢?
- iOS 正则格式判断邮箱失败
- iOS开发:UIAlertView使用的问题
- 请前辈看下这是什么控件啊? 先感谢了!
所以我现在想尝试 下 让这个 btn的 frame 围绕着 UIBezierPath 不知道这样应该怎么实现。
1.如果你使用的是显式动画(就像你现在用的CAKeyframeAnimation),是通过指定path来进行动画的,它的frame并没有改变,点击范围还是0,0这里
2.如果你使用的是隐式动画,是通过设置frame来进行动画的,那么它的点击范围就是200,200这里
copy,还需要注意一个就是 btn的 userinterfaceenable 需要设置为false 这样才能使tap的触发让self.view 获取
copy,还需要注意一个就是 btn的 userinterfaceenable 需要设置为false 这样才能使tap的触发让self.view 获取
userInteraction可以不用设置为false,这个主要看场景,为true的话可以照常接受btn的点击事件,只不过是在btn的frame范围内
UIImageView添加了 tap事件,尝试了下 UIButton userinterfaceenable 一定要设置为NO ,否则不行。至于直接加载self.view上面没有尝试。
orbit.path = path.CGPath;
orbit.duration = 16;
orbit.repeatCount = HUGE_VALF;
/////new add
orbit.removedOnCompletion = NO;
orbit.fillMode= kCAFillModeForwards;