在CGAffineTransformScale之后的视图上的UITapGestureRecognizer

时间:2017-03-02 23:05:31

标签: swift uikit uitapgesturerecognizer cgaffinetransform

我有一个附有UITapGestureRecognizer的UIImageView。点击手势响应正常,一切都在工作,但视图也在运行时由CGAffineTransform动态缩放。在缩放操作之后,只有视图的原始边界响应触摸事件。我需要视图的新缩放边界来响应触摸事件。

UIImageView设置代码:

    --- rest of view and imageView setup ---
    let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(AAImageView.imageTapped))
    imageView.addGestureRecognizer(tapRecognizer)
    imageView.isUserInteractionEnabled = true
    self.addSubview(imageView)

CGAffineTransform代码:

        let annotationView = mapView.view(for: annotation) {
            // Calculate the modification scale factor from the map GSD and scaled image GSD
            let factor = CGFloat(initialMetersPerPoint / mapView.metersPerPoint(atLatitude: annotation.coordinate.latitude))
            // Scale and rotate the image appropriately to maintain position on the map.
            annotationView.imageView.transform = CGAffineTransform(scaleX: factor, y: factor).rotated(by: MGLRadiansFromDegrees(-mapView.direction))
        }

任何建议都将不胜感激

0 个答案:

没有答案