43 lines
1.3 KiB
Swift
43 lines
1.3 KiB
Swift
//
|
|
// BottomView.swift
|
|
// PrivadoVPN
|
|
//
|
|
// Created by Juraldinio on 7/1/21.
|
|
// Copyright © 2021 Privado LLC. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
final class BottomView: NSView {
|
|
|
|
var backgroundColor: NSColor?
|
|
|
|
convenience init(backgroundColor: NSColor) {
|
|
self.init(frame: .zero)
|
|
self.backgroundColor = backgroundColor
|
|
self.translatesAutoresizingMaskIntoConstraints = false
|
|
self.wantsLayer = true
|
|
}
|
|
|
|
override func draw(_ dirtyRect: NSRect) {
|
|
|
|
super.draw(dirtyRect)
|
|
|
|
guard let context = NSGraphicsContext.current?.cgContext else { return }
|
|
|
|
context.move(to: CGPoint(x: dirtyRect.minX, y: dirtyRect.midY))
|
|
|
|
context.addArc(tangent1End: CGPoint(x: dirtyRect.minX, y: dirtyRect.minY), tangent2End: CGPoint(x: dirtyRect.midX, y: dirtyRect.minY), radius: 5)
|
|
context.addArc(tangent1End: CGPoint(x: dirtyRect.maxX, y: dirtyRect.minY), tangent2End: CGPoint(x: dirtyRect.maxX, y: dirtyRect.midY), radius: 5)
|
|
|
|
context.addLine(to: CGPoint(x: dirtyRect.maxX, y: dirtyRect.maxY))
|
|
context.addLine(to: CGPoint(x: dirtyRect.minY, y: dirtyRect.maxY))
|
|
|
|
context.closePath()
|
|
|
|
context.setFillColor(self.backgroundColor?.cgColor ?? .white)
|
|
|
|
context.fillPath()
|
|
}
|
|
}
|