You can use if let
…
override func layoutSubviews() {
super.layoutSubviews()
if let arrSubLayer = layer.sublayers, arrSubLayer.count > 1 {
arrSubLayer[1].cornerRadius = 12
}
self.thumbTintColor = .clear
}
It will check for the sub layers. If any then it will check the count > 1 as you are trying to trying to access index 1.
CLICK HERE to find out more related problems solutions.