Files
comaps/iphone/Maps/Classes/CustomViews/GradientView.swift
Konstantin Pastbin e3e4a1985a 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
2025-05-08 21:10:51 +07:00

51 lines
993 B
Swift

@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()
}
}