ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - Nirma/UIDeviceComplete: UIDevice extensions that fill in the missing pieces.
UIDevice extensions that fill in the missing pieces. - Nirma/UIDeviceComplete
Visit Site

GitHub - Nirma/UIDeviceComplete: UIDevice extensions that fill in the missing pieces.

GitHub - Nirma/UIDeviceComplete: UIDevice extensions that fill in the missing pieces.

UIDeviceComplete

UIDevice extensions that fill in the missing pieces.

Build Status Swift 5.0 CodeCov CocoaPods compatible Carthage compatible Swift Package Manager compatible License

Whats this library about?

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

Features

  • Detect specific device like iPhone 7, iPhone SE or iPad Pro
  • Get screen size of device in inches
  • 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 which 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 .iPhoneX:
        print("So hows that iPhone X notch thing working out? Right...")
    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.screenSize.sizeInches

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 UIDeviceComplete 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, or wish to add any other kind of enhancements, propose to add to the project. 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.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory