thieumao

Is device a iPad?

Mar 8th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.39 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController {
  4.  
  5.     override func viewDidLoad() {
  6.         super.viewDidLoad()
  7.         if UIDevice.isIPad() {
  8.             print("This is an ipad")
  9.         } else {
  10.             print("This is not a ipad")
  11.         }
  12.     }
  13.  
  14. }
  15.  
  16. extension UIDevice {
  17.     static func isIPad() -> Bool {
  18.         return UIDevice.current.userInterfaceIdiom == .pad
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment