Latest 2.0.1
Homepage https://github.com/Nirma/UIDeviceComplete
License MIT
Platforms ios 8.0
Authors

UIDevice extensions that fill in the missing pieces.

Build Status
Swift 4.0
CodeCov
CocoaPods compatible
[CocoaPods]()
Carthage compatible
Swift Package Manager compatible
License

Intro

UIDeviceComplete is an iOS library intended to be a collection of extensions to UIDevice
that provide functionality that UIDevice currently lacks like determining which iOS device
you have (i.e iPhone SE, iPad Pro, iPhone7 etc) or determining the screen size of the device
in inches.

Features

  • [x] Detect specific device like iPhone 7, iPhone SE or iPad Pro
  • [x] Get screen size of device in inches
  • [x] Get iOS Device family (iPod, iPhone or iPad)

Dont see a feature you need?

Feel free to open an Issue requesting the feature you want or send over a pull request!

Use

All of the extensions are called off of the dc variable stands for ([UI]DeviceComplete) object that this
library extends onto UIDevice that way native methods of UIDevice and methods of this library can
easily be seen, also lowering the possibility of naming conflicts.

Getting common device name

UIdevice.current.dc.commonDeviceName // iPad Pro (12.9 inch, Wi-Fi+LTE)

Detecting iOS Device models

let device = UIdevice.current.dc.deviceModel

switch device {
    case .iPhone6Plus, .iPhone7Plus:
        print("Lots of screen realestate eh?")
    case .iPhoneSE, .iPhone5, iPhone5S:
        print("Less iPhone is more iPhone...")
    case .iPadPro:
        print("Why?")
    default:
        print("Not sure what this is...")
}

Detecting iOS Device Screen Size (Inches)

Screen size can be be queried with the following computed property returning a simple Double
that represents the screen size in inches:

let screenSize: Double = UIDevice.current.dc.screen.inches

if screenSize <= 4.0 {
    print("Modest screen size; not so modest price tag")
} else if screenSize >= 5.5 {
    print("Plus is always a plus")
} else {
    print("Chances are this is an iPad or an iPhone (Texas Edition).")
}

Detecting iOS Device Family

If the type of device family is all you are after i.e iPhone or iPad and the specific model
is not important then DeviceFamily might be what you need.

let deviceFamily = UIdevice.current.dc.deviceFamily

switch deviceFamily {
    case .iPhone:
        print("...phone home?")
    case .iPad:
        print("when it comes to screen size; more is more")
    case .iPod:
        print("Why not?")
    default:
        print("No family...")
}

Installation

Carthage

If you use Carthage to manage your dependencies, simply add
UIFontComplete to your Cartfile:

github "Nirma/UIDeviceComplete"

If you use Carthage to build your dependencies, make sure you have added UIDeviceComplete.framework to the "Linked Frameworks and Libraries" section of your target, and have included UIDeviceComplete.framework in your Carthage framework copying build phase.

CocoaPods

If you use CocoaPods to manage your dependencies, simply add
this line to your Podfile:

use_frameworks!
pod 'UIDeviceComplete'

Contributing to this project

Contributions are highly welcome

If there is something you wish to fix about the project,
propose to add to the project or any other kind of enhancement please feel free to send over a pull request
or open an issue for this project.

License

UIDeviceComplete is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "UIDeviceComplete",
    "version": "2.0.1",
    "summary": "UIDevice extensions for device Model, Family, Screen size and more",
    "description": "UIDevice is handy and serves a purpose but it does lack the ability to do things likenprovide the screen size in inches or provide specific device model or family info.nnThats where this library comes in, a super light weight and simple set of extensions tonUIDevice that make UIDevice even more fun to work with.",
    "homepage": "https://github.com/Nirma/UIDeviceComplete",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Nicholas Maccharoli": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Nirma/UIDeviceComplete.git",
        "tag": "2.0.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Sources/*.swift",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This