ALCountryPicker 1.0.4

ALCountryPicker 1.0.4

Abdul维护。



  • Abdul

ALCountryPicker

CI Status Version License Platform

Country Picker

包含国旗和区号的全部国家列表。您可以通过名称、区域代码和区号搜索国家。您可以在不打开国家选择器的情况下获取您当前的国家。对于国旗,使用了 Emoji Unicode.Scalar

需求

  • iOS 10.0+
  • Xcode 9+
  • Swift 4+

示例

要运行示例项目,请先克隆仓库,然后在 Example 目录下运行 pod install

安装

ALCountryPicker 可以通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中

pod 'ALCountryPicker'

入门指南

import UIKit
import ALCountryPicker

class ViewController: UIViewController {

    @IBOutlet weak var countryLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        if let currentCountry = Country.current {
            self.countryLabel.text = currentCountry.flag + " " + currentCountry.countryName +  " (\(String(describing: currentCountry.dialingCode ?? "")))"
        }
        
    }

    @IBAction func openCountry(_ sender: UIButton) {
        CountryPicker.present(on: self) { (country) in
            DispatchQueue.main.async {
                print(country.dialingCode ?? "")
                print(country.flag, "",country.countryName, "", country.countryCode)
                self.countryLabel.text = country.flag + " " + country.countryName +  " (\(String(describing: country.dialingCode ?? "")))"
            }
        }
    }
    
}

gif

countrypicker

屏幕截图

img1 img2

您可以通过拨打代码、区代码和国家名称搜索国家。

img4 img5 img3

作者

Abdul Shamim Khan [email protected]

许可协议

ALCountryPicker 在MIT许可协议下可用。更多信息请参阅LICENSE文件。