Skip to content

A series of helpers and extensions for identifying what device is interacting with your app.

License

Notifications You must be signed in to change notification settings

ianhirschfeld/Swift-DeviceType

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift-DeviceType

A series of helpers and extensions for identifying what device is interacting with your app.

Usage

Get current device type (for use anywhere):

UIDevice.currentDevice().deviceType

Boolean check for device type (for use anywhere):

if UIDevice.currentDevice().isIPhone {
  // Do some iPhone related stuff...
}

Boolean check for view size (for use in a view controller):

if isPhone6Size {
  // Do some iPhone 6 size related stuff...
}

DeviceType Helpers

Below is a list of device models that are recognized. Please note that testing on the simulator always outputs Simulator.

iPodTouch5
iPhone4
iPhone4s
iPhone5
iPhone5c
iPhone5s
iPhone6
iPhone6Plus
iPad2
iPad3
iPad4
iPadAir
iPadAir2
iPadMini
iPadMini2
iPadMini3
Simulator

UIDevice Helpers

UIDevice.currentDevice().deviceType -> DeviceType
UIDevice.currentDevice().isPortrait -> Bool
UIDevice.currentDevice().isLandscape -> Bool
UIDevice.currentDevice().isIPodTouch -> Bool
UIDevice.currentDevice().isIPhone -> Bool
UIDevice.currentDevice().isIPad -> Bool
UIDevice.currentDevice().isSimulator -> Bool

UIViewController Helpers

For brevity only showing examples for iPhone 6.

self.isIPhone6Size -> Bool
self.isIPhone6PortraitSize -> Bool
self.isIPhone6LandscapeSize -> Bool
self.iPhone6Dimensions -> [CGFloat]

About

A series of helpers and extensions for identifying what device is interacting with your app.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published