理解代码

时间:2017-01-10 11:07:49

标签: ios swift annotations mkmapview

我有一个项目是从另一个开发人员编写的,在didSelectAnnotationView内部有以下几行代码:

我无法理解他在height之后使用这些行的原因 我也评论过他们,没有任何改变。

let mapMarker = view.annotation as! MapMaker
self.selMapMarker = mapMarker;

let selectedAnnoView = self.selMapMarker.view

if selectedAnnoView != nil {

    selectedAnnoView?.image = nil;
    selectedAnnoView?.image = UIImage(named: self.selMapMarker.nameImage)
}

var height = (selectedAnnoView?.frame.size.height)! + 10.0;
height = height / mapView.frame.size.height;
height  = 1.0 - height / 2.0;


let markerPoint = self.mapView.convertCoordinate(mapMarker.coordinate, toPointToView: self.mapView);
var mapFrame = self.mapView.convertRegion(self.mapView.region, toRectToView: self.mapView);
mapFrame.origin.y = markerPoint.y - mapFrame.size.height * height;
mapFrame.origin.x = markerPoint.x - mapFrame.size.width / 2.0;

任何人都可以理解他们可以做什么或者没有太多信息?

0 个答案:

没有答案