mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 06:03:45 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
50
iphone/Maps/Classes/CustomViews/GradientView.swift
Normal file
50
iphone/Maps/Classes/CustomViews/GradientView.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
@IBDesignable
|
||||
class GradientView: UIView {
|
||||
enum GradientDirection {
|
||||
case horizontal
|
||||
case vertical
|
||||
}
|
||||
|
||||
var gradientDirection: GradientDirection = .vertical {
|
||||
didSet {
|
||||
let angle = gradientDirection == .horizontal ? -CGFloat.pi / 2 : 0
|
||||
gradientLayer.transform = CATransform3DMakeRotation(angle, 0, 0, 1)
|
||||
}
|
||||
}
|
||||
|
||||
@IBInspectable
|
||||
var startColor: UIColor = .clear {
|
||||
didSet {
|
||||
updateColors()
|
||||
}
|
||||
}
|
||||
|
||||
@IBInspectable
|
||||
var endColor: UIColor = .lightGray {
|
||||
didSet {
|
||||
updateColors()
|
||||
}
|
||||
}
|
||||
|
||||
private func updateColors() {
|
||||
gradientLayer.colors = [startColor.cgColor, endColor.cgColor]
|
||||
}
|
||||
|
||||
override class var layerClass: AnyClass {
|
||||
return CAGradientLayer.self
|
||||
}
|
||||
|
||||
var gradientLayer: CAGradientLayer {
|
||||
return layer as! CAGradientLayer
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
updateColors()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
updateColors()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user