This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FirstClass { | |
fileprivate func someMethod() {} | |
} | |
internal class BusinessClass: FirstClass { | |
override internal func someMethod() {} | |
} | |
private class Tax { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
final class Slider: UISlider { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
final class Slider: UISlider { | |
override func draw(_ rect: CGRect) { | |
super.draw(rect) | |
setup() | |
} | |
private func setup() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class Slider: UISlider { | |
private let baseLayer = CALayer() // Step 3 | |
override func draw(_ rect: CGRect) { | |
super.draw(rect) | |
setup() | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 4 | |
final class ThumbView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
setup() | |
} | |
required init?(coder: NSCoder) { | |
super.init(coder: coder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 4 | |
extension UIView { | |
var snapshot: UIImage { | |
let renderer = UIGraphicsImageRenderer(bounds: bounds) | |
let capturedImage = renderer.image { context in | |
layer.render(in: context.cgContext) | |
} | |
return capturedImage | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 5 | |
private func createThumbImageView() { | |
let thumbSize = (3 * frame.height) / 4 | |
let thumbView = ThumbView(frame: .init(x: 0, | |
y: 0, | |
width: thumbSize, | |
height: thumbSize)) | |
thumbView.layer.cornerRadius = thumbSize / 2 | |
let thumbSnapshot = thumbView.snapshot | |
setThumbImage(thumbSnapshot, for: .normal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 5 | |
private func createThumbImageView() { | |
let thumbSize = (3 * frame.height) / 4 | |
let thumbView = ThumbView(frame: .init(x: 0, | |
y: 0, | |
width: thumbSize, | |
height: thumbSize)) | |
thumbView.layer.cornerRadius = thumbSize / 2 | |
let thumbSnapshot = thumbView.snapshot | |
setThumbImage(thumbSnapshot, for: .normal) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func setup() { | |
clear() | |
createBaseLayer() // Step 3 | |
createThumbImageView() // Step 5 | |
configureTrackLayer() // Step 7 | |
addTarget(self, action: #selector(valueChanged(_:)), for: .valueChanged) // Step 8 | |
} | |
// Step 8 | |
@objc private func valueChanged(_ sender: Slider) { |
OlderNewer