Git Product home page Git Product logo

screentype's Introduction

ScreenType

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.

screentype's People

Contributors

adamswinden avatar allgamesallfree avatar krider2010 avatar viktorgardart avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.