宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
//  StartAnnotationView.swift
//  OKProject
//
//  Created by alvin_y on 2020/6/9.
//  Copyright © 2020 yangwang. All rights reserved.
//
 
import UIKit
 
class StartAnnotationView: MAAnnotationView {
    
    /// 气泡
    let calloutView = StartView.instance()
    
    // 标题
    var title: String = ""{
        didSet{
            calloutView.title = title
            calloutView.isHidden = title == ""
            let width = title.width(UIFont.init(name: Medium, size: 14)!, height: 32) + 65
            self.frame = CGRect(x: 0, y: 0, width: width, height: 32)
        }
    }
    
    override init!(annotation: MAAnnotation!, reuseIdentifier: String!) {
        super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
        setup()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setup()  {
        self.addSubview(calloutView)
        calloutView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
}
 
 
class StartView: UIView {
    
    /// 名称
    @IBOutlet weak var label_name: UILabel!
    
    var title: String = ""{
        didSet{
            self.label_name.text = title
        }
    }
    /// 获取Self
    /// - Returns: Self
    class func instance() -> StartView {
        let v = UINib(nibName: "StartView", bundle: nil).instantiate(withOwner: self, options: nil).first as! StartView
        return v
    }
}