mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-04-19 21:15:21 +00:00
COVIDSafe code from version 1.1
This commit is contained in:
commit
3640e52eb2
330 changed files with 261540 additions and 0 deletions
42
CovidSafe/UIElements/GradientButton.swift
Normal file
42
CovidSafe/UIElements/GradientButton.swift
Normal file
|
@ -0,0 +1,42 @@
|
|||
//
|
||||
// GradientButton.swift
|
||||
// CovidSafe
|
||||
//
|
||||
// Copyright © 2020 Australian Government. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@IBDesignable
|
||||
class GradientButton: UIButton {
|
||||
let gradientLayer = CAGradientLayer()
|
||||
|
||||
@IBInspectable
|
||||
var topGradientColor: UIColor?
|
||||
|
||||
@IBInspectable
|
||||
var bottomGradientColor: UIColor?
|
||||
|
||||
private func setGradient(topGradientColor: UIColor?, bottomGradientColor: UIColor?) {
|
||||
if let topGradientColor = topGradientColor, let bottomGradientColor = bottomGradientColor {
|
||||
gradientLayer.frame = bounds
|
||||
gradientLayer.colors = [topGradientColor.cgColor, bottomGradientColor.cgColor]
|
||||
gradientLayer.borderColor = layer.borderColor
|
||||
gradientLayer.borderWidth = layer.borderWidth
|
||||
gradientLayer.cornerRadius = layer.cornerRadius
|
||||
gradientLayer.startPoint = CGPoint(x: 0, y: 0)
|
||||
gradientLayer.endPoint = CGPoint(x: 1, y: 0)
|
||||
gradientLayer.locations = [0.0, 1.0]
|
||||
layer.insertSublayer(gradientLayer, at: 0)
|
||||
} else {
|
||||
gradientLayer.removeFromSuperlayer()
|
||||
}
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
setGradient(topGradientColor: topGradientColor, bottomGradientColor: bottomGradientColor)
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue