Skip to content

Commit

Permalink
[framework] Fix radial gradient rendering poorly for whatever reason
Browse files Browse the repository at this point in the history
  • Loading branch information
kirb committed May 14, 2022
1 parent f137f68 commit 2876ed3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Alderis/ColorPickerWheelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ private class ColorPickerWheelInnerView: UIView {

var handleLayout: (() -> Void)!

private var saturationMask: GradientView!

override init(frame: CGRect) {
super.init(frame: frame)

Expand All @@ -201,16 +203,19 @@ private class ColorPickerWheelInnerView: UIView {
hueView.gradientLayer.transform = CATransform3DMakeRotation(0.5 * .pi, 0, 0, 1)
addSubview(hueView)

let saturationView = GradientView()
let saturationView = UIView()
saturationView.translatesAutoresizingMaskIntoConstraints = false
saturationView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
saturationView.gradientLayer.type = .radial
saturationView.gradientLayer.colors = [UIColor.white.cgColor, UIColor.clear.cgColor]
saturationView.gradientLayer.locations = [0, 1]
saturationView.gradientLayer.startPoint = CGPoint(x: 0.5, y: 0.5)
saturationView.gradientLayer.endPoint = CGPoint(x: 1, y: 1)
saturationView.backgroundColor = .white
addSubview(saturationView)

saturationMask = GradientView()
saturationMask.gradientLayer.type = .radial
saturationMask.gradientLayer.colors = [UIColor.white.cgColor, UIColor.clear.cgColor]
saturationMask.gradientLayer.startPoint = CGPoint(x: 0.5, y: 0.5)
saturationMask.gradientLayer.endPoint = CGPoint(x: 1, y: 1)
saturationView.mask = saturationMask

brightnessView = UIView()
brightnessView.translatesAutoresizingMaskIntoConstraints = false
brightnessView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
Expand All @@ -229,6 +234,7 @@ private class ColorPickerWheelInnerView: UIView {
override func layoutSubviews() {
super.layoutSubviews()
layer.cornerRadius = frame.size.height / 2
saturationMask.frame = bounds
handleLayout()
}
}

0 comments on commit 2876ed3

Please sign in to comment.