アニメーション中にUILabelのタップ判定がしたいです。
そこでlayerのようなものが必要と知り、containsで判定して見ましたが、押したviewの位置によってタグが判定されてしまい、どのタグのラベルを押したかの判定ができません。
このlayerについて、viewとpresentation()で取れるアニメーション中の座標で判定するんだ程度しか、理解しておらず何がいけないのかがわかりません。
ちなみにpresentationで取れる座標はoptionalでずっと最初の値になっています。
どなたかご教授いただけると幸いです。よろしくお願いします。
swift
1 @objc func tap(_ gestureRecognizer: UIGestureRecognizer) { 2 let point = gestureRecognizer.location(in: scrollView) 3 print(point) 4 let target:UILabel! = self.view.viewWithTag(1) as! UILabel 5 let location = target.layer.presentation()?.frame 6 print(location) 7 8 if location!.contains(point){ 9 print("yes") 10 } 11 }
いくつかお伺いしたいのですが、tapメソッドはscrollViewがタップされた際に呼ばれるものでしょうか?また、targetはscrollViewの子Viewであるという認識でよろしいでしょうか?
あなたの回答
tips
プレビュー