//
|
// UserAnnotationView.swift
|
// QuanKeTong
|
//
|
// Created by alvin_y on 2019/6/13.
|
// Copyright © 2019 yang-wang. All rights reserved.
|
//
|
|
import UIKit
|
|
class UserAnnotationView: MAAnnotationView {
|
|
/// 气泡
|
let calloutView = UserCalloutView.instance()
|
|
/// 气泡点击回调
|
var onTapCallout:((_ annotation: MAAnnotation) -> Void)?
|
|
/// 着色
|
var yy_tintColor = UIColor.color(hexString: "#333333")
|
|
/// 字体
|
var yy_font = UIFont.systemFont(ofSize: 12)
|
|
/// 着色
|
var yy_isTintColor = false
|
|
/// 标题
|
var title: String = "" {
|
didSet{
|
calloutView.yy_isTintColor = yy_isTintColor
|
calloutView.yy_tintColor = yy_tintColor
|
calloutView.yy_font = yy_font
|
calloutView.title = title
|
calloutView.isHidden = title == ""
|
}
|
}
|
|
override init!(annotation: MAAnnotation!, reuseIdentifier: String!) {
|
super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
|
setup()
|
}
|
|
|
func setup() {
|
calloutView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(calloutViewActtion)))
|
self.addSubview(calloutView)
|
calloutView.title = title
|
calloutView.isHidden = title == ""
|
calloutView.snp.makeConstraints { (make) in
|
make.centerX.equalToSuperview()
|
make.centerY.equalToSuperview().offset(-36)
|
make.size.greaterThanOrEqualTo(CGSize(width: 20, height: 10))
|
}
|
}
|
|
|
/// 气泡点击
|
@objc func calloutViewActtion() {
|
onTapCallout?(self.annotation)
|
}
|
|
override init(frame: CGRect) {
|
super.init(frame: frame)
|
|
}
|
|
required init?(coder aDecoder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
}
|