TimeZonePicker
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.
屏幕截图
安装
CocoaPods
要在您的 iOS 项目中安装它,请使用 CocoaPods 进行安装。
pod 'TimeZonePicker'
使用方式
基本初始化
要初始化一个timeZonePicker
,您可以在TimeZonePickerViewController
上使用类函数getVC(withDelegate: TimeZonePickerDelegate)
,如下所示:
let timeZonePicker = TimeZonePickerViewController.getVC(withDelegate: self)
然后您可以使用timeZonePicker
,就像任何UIViewController
一样,例如:
present(timeZonePicker, animated: true, completion: nil)
TimeZonePickerDelegate
TimeZonePickerDelegate
目前只有一个需要实现的方法
func timeZonePicker(_ timeZonePicker: TimeZonePickerViewController, didSelectTimeZone timeZone: TimeZone)
一旦从城市/国家表中选择了一项,就会调用上述代理方法,方便地返回TimeZonePickerViewController
和选中的TimeZone
。您可以使用timeZonePicker
在这里取消显示,并使用timeZone
根据您的应用需要。例如:
func timeZonePicker(_ timeZonePicker: TimeZonePickerViewController, didSelectTimeZone timeZone: TimeZone) {
timeZoneName.text = timeZone.identifier
timeZoneOffset.text = timeZone.abbreviation()
timeZonePicker.dismiss(animated: true, completion: nil)
}
请检查TimeZonePickerExample
项目以获取上述用法示例。如果您有任何问题,请不要犹豫与我联系。
要求
- iOS 8或更高版本。
- Swift 3
许可证
Copyright (c) 2017 Gligor Kotushevski
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.