TimeZonePicker
  • April 25, 2024

A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your most suitable time zone.

Screenshots


Installation


CocoaPods

To install it in your iOS project, install with CocoaPods

pod ‘TimeZonePicker’

Usage


Basic Initialisation

To initialise a timeZonePicker you can use the class function getVC(withDelegate: TimeZonePickerDelegate) on the TimeZonePickerViewController as below:

let timeZonePicker = TimeZonePickerViewController.getVC(withDelegate: self)

Then you can use the timeZonePicker as you would any UIViewController, for example:

present(timeZonePicker, animated: true, completion: nil)

TimeZonePickerDelegate

The TimeZonePickerDelegate currently has only one method that needs to be implemented:

func timeZonePicker(_ timeZonePicker: TimeZonePickerViewController, didSelectTimeZone timeZone: TimeZone)

Once an item is selected from the table of cities/countries the above delegate method gets called, conveniently returning the TimeZonePickerViewController and the selected TimeZone. You can use the timeZonePicker to dismiss it here and the timeZone as you need it in your application. For example:

func timeZonePicker(_ timeZonePicker: TimeZonePickerViewController, didSelectTimeZone timeZone: TimeZone) {
timeZoneName.text = timeZone.identifier
timeZoneOffset.text = timeZone.abbreviation()
timeZonePicker.dismiss(animated: true, completion: nil)
}

Please check the TimeZonePickerExample project for the above usage example. If you have any questions do not hesitate to get in touch with me.

Requirements


  • iOS 8 or later.
  • Swift 3

GitHub


View Github

#swift #swift-3 #swift3 #timezone #timezone-library #timezone-list #timezone-picker #timezones
YOU MIGHT ALSO LIKE...
CameraBackground

Features Both front and back camera supported. Flash modes: auto, on, off. Countdown timer. Tap to focus. Pinch to zoom. Usage  

DKCamera

Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so ...

HorizonSDK-iOS

Horizon SDK is a state of the art real-time video recording / photo shooting iOS library. Some of the features ...

LLSimpleCamera

LLSimpleCamera: A simple customizable camera - video recorder control LLSimpleCamera is a library for creating a customized camera - video ...

RSBarcodes_Swift

RSBarcodes allows you to read 1D and 2D barcodes using the metadata scanning capabilities introduced with iOS 7 and generate ...