Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 当滚动mapView或点击标记时,如何创建具有自定义注释和区域焦点的地图?_Ios_Swift_Mapkit_Mkannotation_Mkannotationview - Fatal编程技术网

Ios 当滚动mapView或点击标记时,如何创建具有自定义注释和区域焦点的地图?

Ios 当滚动mapView或点击标记时,如何创建具有自定义注释和区域焦点的地图?,ios,swift,mapkit,mkannotation,mkannotationview,Ios,Swift,Mapkit,Mkannotation,Mkannotationview,我想用UIView实现一个MapKit,它与TripAdvisor和ClassPass应用程序具有相同的效果。基本上,我想在视图的底部添加一个可滚动视图,当用户在地图中滚动时,带有标记信息的底部视图会随着新标记的详细信息而改变 我想要实现的示例: ClassPass应用程序的第二个示例: 第三个示例,代码为React Native: 我能够用标记和UIView创建苹果地图,如下面链接中的下一张图片所示: 但是,我希望根据地图区域或点击标记时动态更改UIView。我怎样才能达到这个结果

我想用UIView实现一个MapKit,它与TripAdvisor和ClassPass应用程序具有相同的效果。基本上,我想在视图的底部添加一个可滚动视图,当用户在地图中滚动时,带有标记信息的底部视图会随着新标记的详细信息而改变

我想要实现的示例:

ClassPass应用程序的第二个示例:

第三个示例,代码为React Native:

我能够用标记和UIView创建苹果地图,如下面链接中的下一张图片所示:

但是,我希望根据地图区域或点击标记时动态更改UIView。我怎样才能达到这个结果

以下是当前代码:


  @IBOutlet weak var reviewView2: DesignableView!
    @IBOutlet weak var authorLabel: UILabel!


    @IBOutlet weak var reviewLabel: UILabel!


    @IBOutlet weak var Star1: UIImageView!

    @IBOutlet weak var Star2: UIImageView!

    @IBOutlet weak var Star3: UIImageView!

    @IBOutlet weak var Star4: UIImageView!

    @IBOutlet weak var Star5: UIImageView!

    @IBOutlet weak var authorImageView: UIImageView!
    @IBOutlet weak var reviewView: DesignableView!

    var gpxURL: NSURL? {
        didSet {
            clearWaypoints()
             if let url = gpxURL {
                GPX.parse(url: url as URL) { gpx in      // asynchronous
                        if gpx != nil {
                              self.addWayPoints(waypoints: gpx!.waypoints)
                        }
                }
            }
        }
    }

   let urlstring = "Long_Lat"

    override func viewDidLoad() {
        super.viewDidLoad()
//        gpxURL = URL(string: urlstring)
        gpxURL = Bundle.main.url(forResource: urlstring, withExtension: "gpx") as NSURL?

        reviewView.isHidden = true
        reviewView2.isHidden = true


    }

 @IBAction func reviewViewsTapped(_ sender: UITapGestureRecognizer) {
        print("Button tapped")
    }




     // MARK: - MKMapViewDelegate

    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
     var view = mapView.dequeueReusableAnnotationView(withIdentifier: Constants.AnnotationViewReuseIdentifier)

     if view == nil {
         view = MKPinAnnotationView(annotation: annotation, reuseIdentifier: Constants.AnnotationViewReuseIdentifier)


        }else{
               view?.annotation = annotation
           }

        view?.canShowCallout = false

           guard !annotation.isKind(of: MKUserLocation.self) else {
               //for the custom image on current location
                   view?.image = #imageLiteral(resourceName: "gift")
                   return view
           }


        view?.image = UIImage(named: "gift")

        let scaleTransform = CGAffineTransform(scaleX: 0.0, y: 0.0)  // Scale
        UIView.animate(withDuration: 0.2, animations: {
            view?.transform = scaleTransform
            view?.layoutIfNeeded()
        }) { (isCompleted) in

            // Nested block of animation
            UIView.animate(withDuration: 0.3, animations: {
                view?.alpha = 1.0
                view?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
                AnimationUtility.viewSlideInFromBottom(toTop: view!)
                view?.layoutIfNeeded()
            })
        }


     return view
 }

你知道如何使用Swift 5和UIKit来实现吗

提前感谢

你可以使用谷歌地图, 设置您的自定义地图标记它有所有的方法,您可以在这里阅读更多

我认为最好的例子是ClassPass,不同的是我希望在用户更改地图区域时更改包含用户信息的视图。ClassPass使用MapKit,而不是Google地图。