-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// StatusBarOverlayView.swift | ||
// Bank | ||
// | ||
// Created by Ayden Panhuyzen on 2017-12-04. | ||
// Copyright © 2017 Ayden Panhuyzen. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class StatusBarOverlayView: UIView { | ||
private var gradientView: BackgroundGradientView!, gradientViewHeightAnchor: NSLayoutConstraint?, hairlineView: HairlineView! | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
translatesAutoresizingMaskIntoConstraints = false | ||
clipsToBounds = true | ||
|
||
gradientView = BackgroundGradientView() | ||
gradientView.translatesAutoresizingMaskIntoConstraints = false | ||
addSubview(gradientView) | ||
gradientView.topAnchor.constraint(equalTo: topAnchor).isActive = true | ||
gradientView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true | ||
gradientView.rightAnchor.constraint(equalTo: rightAnchor).isActive = true | ||
|
||
hairlineView = HairlineView() | ||
hairlineView.translatesAutoresizingMaskIntoConstraints = false | ||
hairlineView.backgroundColor = UIColor(white: 0, alpha: 0.15) | ||
hairlineView.alpha = 0 | ||
addSubview(hairlineView) | ||
hairlineView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true | ||
hairlineView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true | ||
hairlineView.rightAnchor.constraint(equalTo: rightAnchor).isActive = true | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
/// The height anchor to use to layout the gradient view (to match the background of the view controller) | ||
var viewHeightAnchor: NSLayoutDimension? { | ||
didSet { | ||
gradientViewHeightAnchor?.isActive = false | ||
guard let anchor = viewHeightAnchor else { return } | ||
gradientViewHeightAnchor = gradientView.heightAnchor.constraint(equalTo: anchor) | ||
gradientViewHeightAnchor!.isActive = true | ||
} | ||
} | ||
|
||
/// Whether or not the hairline view should be shown. | ||
var isHairlineVisible = false { | ||
didSet { | ||
if isHairlineVisible == oldValue { return } | ||
UIView.animate(withDuration: 0.1) { self.hairlineView.alpha = self.isHairlineVisible ? 1 : 0 } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// HairlineView.swift | ||
// | ||
// Created by Ayden Panhuyzen on 2017-08-21. | ||
// Copyright © 2017 Ayden Panhuyzen. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class HairlineView: UIView { | ||
private var heightConstraint: NSLayoutConstraint? | ||
|
||
override func didMoveToWindow() { | ||
super.didMoveToWindow() | ||
translatesAutoresizingMaskIntoConstraints = false | ||
heightConstraint?.isActive = false | ||
heightConstraint = heightAnchor.constraint(equalToConstant: 1 / (window?.screen.scale ?? 1)) | ||
heightConstraint!.isActive = true | ||
} | ||
} | ||
|