Latest 1.1.0
Homepage https://github.com/allgamesallfree/ScreenType
License MIT
Platforms ios 9.0
Authors

ScreenType

Version
License
Platform

Easily distinguish between iPhone models in Objective-C and Swift.

Example

To demo the example project, clone or download the repo, and open "ScreenType.xcworkspace" from the "Example" directory.

Requirements

Swift 4.0+

Xcode 9.0+

iOS 9.0+

Installation

ScreenType is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'ScreenType'

Manual Installation

Install ScreenType manually by importing ScreenType.swift into your project

Usage

Swift

If you’re using Cocoapods add: import ScreenType prior to using ScreenType in your file.

// Check for a specific model
if UIScreen.current == .iPhone5_8 {
    print("Screen type is iPhone X")
}

// Check for multiple models
if UIScreen.current == .iPhone4_7 || UIScreen.current == .iPhone5_5 {
    print("Screen type is either iPhone 6/7/8 or 6/7/8 Plus")
}

// Find all models smaller than a certain screen size
if UIScreen.current < .iPhone4_7 {
    print("Screen is smaller than an iPhone 6/7/8")
}

// Find all models larger than or equal to a certain screen size
if UIScreen.current >= .iPad10_5 {
    print("Screen type is either iPad 10.5 or iPad 12.9")
}

Objective-C

You’ll need a bridging header in order to use ScreenType in Objective-C.

If you’re using Cocoapods add @import ScreenType; to the top of your file as well.

// Check for a specific model
if ([UIScreen current] == ScreenTypeIPhone5_8) {
    NSLog(@"Screen Type is iPhone X");
}

// Find all models larger than a certain screen size
if ([UIScreen current] > ScreenTypeIPhone4_0) {
    NSLog(@"Screen is larger than an iPhone 5/S/C");
}

Contributions

You are welcome to fork and submit pull requests

Author

Max Stein | maxste.in | Twitter

License

ScreenType is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ScreenType",
    "version": "1.1.0",
    "summary": "Easily distinguish between iPhone models in Objective-C and Swift",
    "description": "Enables you to use UIScreen.current to get the ScreenType of the current device and see if it is equal to, greater than, or less than a particular iPhone or iPad model's size.",
    "homepage": "https://github.com/allgamesallfree/ScreenType",
    "screenshots": [
        "https://raw.githubusercontent.com/allgamesallfree/ScreenType/master/ScreenType.png",
        "https://raw.githubusercontent.com/allgamesallfree/ScreenType/master/ScreenType.gif"
    ],
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Max Stein": "[email protected]"
    },
    "source": {
        "git": "https://github.com/allgamesallfree/ScreenType.git",
        "tag": "1.1.0"
    },
    "social_media_url": "https://twitter.com/maxsteinapps",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "ScreenType/Classes/**/*"
}

Pin It on Pinterest

Share This