|
@@ -0,0 +1,86 @@
|
|
|
+//
|
|
|
+// PopTopTriangleView.swift
|
|
|
+// RainbowPlanet
|
|
|
+//
|
|
|
+// Created by Christopher on 2019/5/22.
|
|
|
+// Copyright © 2019 RainbowPlanet. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+import UIKit
|
|
|
+
|
|
|
+class PopTopTriangleView: BaseView {
|
|
|
+
|
|
|
+ var address: String? {
|
|
|
+ didSet {
|
|
|
+ addressLabel.text = self.address
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupViews() {
|
|
|
+ self.backgroundColor = kffffffColor
|
|
|
+ addSubview(triangleView)
|
|
|
+ addSubview(contentView)
|
|
|
+ contentView.addSubview(addressLabel)
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupLayouts() {
|
|
|
+ triangleView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalToSuperview()
|
|
|
+ make.left.equalToSuperview().offset(4)
|
|
|
+ make.width.equalTo(15)
|
|
|
+ make.height.equalTo(8)
|
|
|
+ }
|
|
|
+
|
|
|
+ contentView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(triangleView.snp_bottom)
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(24)
|
|
|
+ }
|
|
|
+
|
|
|
+ addressLabel.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalToSuperview().offset(5)
|
|
|
+ make.right.equalToSuperview().offset(-8)
|
|
|
+ make.bottom.equalToSuperview().offset(-5)
|
|
|
+ make.height.equalTo(14)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private lazy var triangleView: UIView = {
|
|
|
+ let triangleView = UIView(frame: CGRect(x: 0, y: 0, width: 8, height: 14))
|
|
|
+ triangleView.backgroundColor = kffffffColor
|
|
|
+
|
|
|
+ // 画三角
|
|
|
+ let trianglePath = UIBezierPath()
|
|
|
+ var point = CGPoint(x: 0, y: 8)
|
|
|
+ trianglePath.move(to: point)
|
|
|
+ point = CGPoint(x: 14/2, y: 0)
|
|
|
+ trianglePath.addLine(to: point)
|
|
|
+ point = CGPoint(x: 14, y: 8)
|
|
|
+ trianglePath.addLine(to: point)
|
|
|
+ trianglePath.close()
|
|
|
+ let triangleLayer = CAShapeLayer()
|
|
|
+ triangleLayer.path = trianglePath.cgPath
|
|
|
+ triangleLayer.fillColor = kRGBAColor(r: 0, g: 0, b: 0, a: 0.6).cgColor
|
|
|
+ triangleView.layer.addSublayer(triangleLayer)
|
|
|
+ return triangleView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var contentView: UIView = {
|
|
|
+ let contentView = UIView()
|
|
|
+ contentView.backgroundColor = UIColor.black
|
|
|
+ contentView.alpha = 0.6
|
|
|
+ contentView.cornerRadius = 2
|
|
|
+ contentView.masksToBounds = true
|
|
|
+ return contentView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var addressLabel: UILabel = {
|
|
|
+ let addressLabel = UILabel()
|
|
|
+ addressLabel.text = "建设西路新旅城南门自提点"
|
|
|
+ addressLabel.textColor = kffffffColor
|
|
|
+ addressLabel.font = kScaleRegularFont14
|
|
|
+ return addressLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+}
|