//
|
// 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)
|
}
|
}
|
}
|