Detecting iPad or iPhone in swift

To detect if the user is using an iPad or iPhone or something else in Swift do something like this:

switch UIDevice.current.userInterfaceIdiom {
 case .phone:
 deviceLavel.text = "iPhone"
 case .pad:
 deviceLavel.text = "iPad"
 case .unspecified:
 deviceLavel.text = "unspecified"
 case .tv:
 deviceLavel.text = "tv"
 case .carPlay:
 deviceLavel.text = "carPlay"
 }

Leave a Comment

Your email address will not be published. Required fields are marked *