宽窄优行-由【嘉易行】项目成品而来
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
60
61
62
63
64
65
66
67
68
69
70
71
//
//  YYTitleAnnotation.swift
//  OKProject
//
//  Created by alvin_y on 2020/9/17.
//  Copyright © 2020 yangwang. All rights reserved.
//
 
import UIKit
 
class YYTitleAnnotation: MAPointAnnotation {
    
    
}
 
class YYTitleAnnotationView: MAAnnotationView {
    
    static let reuseIdentifier = String(describing: YYTitleAnnotationView.self)
    
    let view_shadow = UIView()
    let view_cornerRadius = UIView()
    let label_title = UILabel()
    
    override init!(annotation: MAAnnotation!, reuseIdentifier: String!) {
        super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
        
        setupViews()
        defineLayouts()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupViews() {
        label_title.font = UIFont.systemFont(ofSize: 14, weight: .medium)
        label_title.textColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.8)
        view_shadow.addShadow(ofColor: .black, radius: 5, offset: .zero, opacity: 0.1)
        addSubview(view_shadow)
        
        view_cornerRadius.cornerRadius = 16
        view_cornerRadius.backgroundColor = .white
        view_shadow.addSubview(view_cornerRadius)
        let attributedText = AttributedStringbuilder.build()
            .add(string: "正为您寻找车辆 等待", withFont: UIFont.systemFont(ofSize: 14, weight: .medium), withColor: #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.8))
            .add(string: "00:00", withFont: UIFont.systemFont(ofSize: 14, weight: .medium), withColor: #colorLiteral(red: 0.8901960784, green: 0.0431372549, blue: 0.0431372549, alpha: 1))
            .mutableAttributedString
        label_title.attributedText = attributedText
        view_cornerRadius.addSubview(label_title)
    }
    
    func defineLayouts() {
        
        view_shadow.snp.makeConstraints { (make) in
            make.bottom.equalTo(self.snp.top).offset(-10)
            make.centerX.equalTo(self)
            make.height.equalTo(32)
        }
        
        view_cornerRadius.snp.makeConstraints { (make) in
            make.edges.equalTo(view_shadow)
        }
        
        label_title.snp.makeConstraints { (make) in
            make.left.equalTo(view_cornerRadius).offset(10)
            make.right.equalTo(view_cornerRadius).offset(-10)
            make.top.bottom.equalTo(view_cornerRadius)
            make.width.greaterThanOrEqualTo(60)
        }
    }
}