-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLegendBarView.swift
More file actions
47 lines (39 loc) · 1.42 KB
/
Copy pathLegendBarView.swift
File metadata and controls
47 lines (39 loc) · 1.42 KB
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
//
// LegendBarView.swift
// Coursica
//
// Created by Regan Bell on 9/6/15.
// Copyright (c) 2015 Prestige Worldwide. All rights reserved.
//
import UIKit
import Cartography
class LegendBarView: UIView {
let circleView = UIView(frame: CGRect(x: 0, y: 0, width: 16, height: 16))
let titleLabel = UILabel()
init(title: String, color: UIColor) {
super.init(frame: CGRectZero)
backgroundColor = UIColor.whiteColor()
opaque = true
circleView.backgroundColor = color
circleView.layer.cornerRadius = 8
addSubview(circleView)
titleLabel.text = title
titleLabel.textColor = UIColor.blackColor()
titleLabel.backgroundColor = UIColor.whiteColor()
titleLabel.opaque = true
titleLabel.numberOfLines = 0
titleLabel.font = UIFont(name: "AvenirNext-DemiBold", size: 15)
addSubview(titleLabel)
constrain(self, circleView, titleLabel, block: {container, circle, title in
circle.left == container.left
circle.width == 16
circle.height == 16
circle.centerY == container.centerY
title.top == container.top
title.left == circle.right + 10
title.right == container.right
container.height == 20
})
}
required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }
}