You are announcing the iPhone and iPad globally to access anywhere in your project. Then try like this:
let IsIPhone = UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone
let IsIPad = UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad
You can check the iPhone and iPad as follows:
func setup() {
if IsIPad{
backgroundArcLayer.lineWidth = 36.0
backgroundArcLayer.fillColor = nil
backgroundArcLayer.strokeEnd = 2
layer.addSublayer(backgroundArcLayer)
frontArcLayer.lineWidth = 36.0
frontArcLayer.fillColor = nil
frontArcLayer.strokeEnd = 1.0
layer.addSublayer(frontArcLayer)
}else{
backgroundArcLayer.lineWidth = 18.0
backgroundArcLayer.fillColor = nil
backgroundArcLayer.strokeEnd = 1
layer.addSublayer(backgroundArcLayer)
frontArcLayer.lineWidth = 18.0
frontArcLayer.fillColor = nil
frontArcLayer.strokeEnd = 0.5
layer.addSublayer(frontArcLayer)
}
}
This is good for checking iPad and iPhone.
source
share