Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
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()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue