-
Notifications
You must be signed in to change notification settings - Fork 895
/
Copy pathCallReceptionControl.swift
42 lines (33 loc) · 1.06 KB
/
CallReceptionControl.swift
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
//
// CallReceptionControl.swift
// Telegram
//
// Created by Mikhail Filimonov on 13/08/2020.
// Copyright © 2020 Telegram. All rights reserved.
//
import Cocoa
import TGUIKit
class CallReceptionControl: View {
var reception: Int32 = 4 {
didSet {
self.needsDisplay = true
}
}
override func draw(_ layer: CALayer, in context: CGContext) {
super.draw(layer, in: context)
context.setFillColor(NSColor.white.cgColor)
let width: CGFloat = 3.0
let spacing: CGFloat = 2.0
for i in 0 ..< 4 {
let height = 4.0 + 2.0 * CGFloat(i)
let rect = CGRect(x: bounds.minX + CGFloat(i) * (width + spacing), y: frame.height - height, width: width, height: height)
if i >= reception {
context.setAlpha(0.4)
}
let path = CGMutablePath()
path.addRoundedRect(in: rect, cornerWidth: 0.5, cornerHeight: 0.5)
context.addPath(path)
context.fillPath()
}
}
}