ianhirschfeld / Swift-DeviceType

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License:MIT License


Languages

Language:Swift 98.5%Language:Objective-C 1.5%