Code Monkey home page Code Monkey 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 == .iPhoneX {
    print("Screen type is iPhone X")
}

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

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

// 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] == ScreenTypeIPhoneX) {
    NSLog(@"Screen Type is iPhone X");
}

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

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

allgamesallfree avatar

Watchers

Claire avatar James Cloos 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.