Skip to content

A library for determining the actual physical size of pixels on an iOS device.

License

Notifications You must be signed in to change notification settings

bamlab/IRLSize

 
 

Repository files navigation

IRLSize

IRLSize is an iOS library in Objective-C for converting physical measurements (in millimeters) to device-specific density-independent pixels (dp) for Swift applications. The library includes properties for retrieving the physical dimensions of a device’s screen and a utility method to convert millimeter sizes to dp without needing a Swift bridge.

Features

  • Retrieve physical screen height and width in millimeters for supported iOS devices.
  • Convert millimeter values to dp accurately based on device-specific measurements.
  • Fallback handling for unsupported devices.

Installation

Using CocoaPods

Add IRLSize to your Podfile:

pod 'IRLSize', :git => 'https://github.com/bamlab/IRLSize', :branch => 'main'

Usage

Swift Integration

To use IRLSize in Swift:

  1. Import the module.
  2. IRLDeviceMeasurements.
  3. Access properties and call methods directly.

Example:

import IRLSize

let deviceMeasurements = IRLDeviceMeasurements()
let heightInMm = deviceMeasurements.rawPhysicalScreenHeight
let widthInMm = deviceMeasurements.rawPhysicalScreenWidth
let sizeInDp = deviceMeasurements.convertMmSize(toDp: 20) // Convert 20 mm to dp

Supported Devices

IRLSize includes predefined physical dimensions for popular iOS devices. For unsupported devices, the library defaults to the dimensions of an iPhone 11.

If you need to add support for additional devices, refer to Apple’s Accessory Design Guidelines to obtain accurate measurements (find in the table of content the device, look at the schema's and the size is the display active area).

Contributing

Contributions to expand device support or improve conversion accuracy are welcome! Please submit a pull request.

Historic

This was a fork from https://github.com/detroit-labs/IRLSize however it is not maintained anymore and could not be simply patch. This is why it has been forked and rework to just compute the size.

About

A library for determining the actual physical size of pixels on an iOS device.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 67.1%
  • Ruby 20.2%
  • Makefile 12.7%