summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/HeaderBarView.swift
blob: be9207619055886f9e2cfc18e224423b81dc2052 (plain)
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
//
//  HeaderBarView.swift
//  MullvadVPN
//
//  Created by pronebird on 19/06/2020.
//  Copyright © 2020 Mullvad VPN AB. All rights reserved.
//

import Foundation
import UIKit

class HeaderBarView: UIView {
    @IBOutlet var contentView: UIView!
    @IBOutlet var settingsButton: UIButton!

    init(bundle: Bundle?) {
        super.init(frame: .zero)

        loadFromNib(bundle: bundle)
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    private func loadFromNib(bundle: Bundle?) {
        let nib = UINib(nibName: "HeaderBarView", bundle: bundle)
        _ = nib.instantiate(withOwner: self, options: nil)

        let constraints = [contentView.leadingAnchor.constraint(equalTo: leadingAnchor),
                           contentView.trailingAnchor.constraint(equalTo: trailingAnchor),
                           contentView.topAnchor.constraint(equalTo: topAnchor),
                           contentView.bottomAnchor.constraint(equalTo: bottomAnchor)]

        contentView.translatesAutoresizingMaskIntoConstraints = false
        addSubview(contentView)

        NSLayoutConstraint.activate(constraints)
    }
}