Skip to content

Instantly share code, notes, and snippets.

@barisuyar
Created December 1, 2021 19:24
Show Gist options
  • Select an option

  • Save barisuyar/be74b3da55198fd0cda6c6b09ca0311b to your computer and use it in GitHub Desktop.

Select an option

Save barisuyar/be74b3da55198fd0cda6c6b09ca0311b to your computer and use it in GitHub Desktop.
Slider + TrackLayer
private let trackLayer = CAGradientLayer() // Step 7
// Step 7
private func configureTrackLayer() {
let firstColor = UIColor(red: 210/255, green: 152/255, blue: 238/255, alpha: 1).cgColor
let secondColor = UIColor(red: 166/255, green: 20/255, blue: 217/255, alpha: 1).cgColor
trackLayer.colors = [firstColor, secondColor]
trackLayer.startPoint = .init(x: 0, y: 0.5)
trackLayer.endPoint = .init(x: 1, y: 0.5)
trackLayer.frame = .init(x: 0,
y: frame.height / 4,
width: 0,
height: frame.height / 2)
trackLayer.cornerRadius = trackLayer.frame.height / 2
layer.insertSublayer(trackLayer, at: 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment