-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathREADME.md
88 lines (61 loc) · 3.07 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# MRCountryPicker
[](http://cocoapods.org/pods/MRCountryPicker)
[](http://cocoapods.org/pods/MRCountryPicker)
[](https://travis-ci.org/xtrinch/MRCountryPicker)
[](http://cocoapods.org/pods/MRCountryPicker)
[](http://cocoapods.org/pods/MRCountryPicker)
[](https://github.com/Carthage/Carthage)
Versions below 0.0.4 are Swift 2.2 compatible, versions 0.0.5-0.0.7 are Swift 3 compatible, versions 0.0.8+ are Swift 4 compatible.
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.

## Usage
Make your UIPickerView a class of MRCountryPicker, set its countryPickerDelegate and implement its countryPhoneCodePicker method.
See the following example:
```
class ViewController: UIViewController, MRCountryPickerDelegate {
@IBOutlet weak var countryPicker: MRCountryPicker!
@IBOutlet weak var countryName: UILabel!
@IBOutlet weak var countryCode: UILabel!
@IBOutlet weak var countryFlag: UIImageView!
@IBOutlet weak var phoneCode: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
countryPicker.countryPickerDelegate = self
countryPicker.showPhoneNumbers = true
// set country by its code
countryPicker.setCountry("SI")
// optionally set custom locale; defaults to system's locale
countryPicker.setLocale("sl_SI")
// set country by its name
countryPicker.setCountryByName("Canada")
}
// a picker item was selected
func countryPhoneCodePicker(_ picker: MRCountryPicker, didSelectCountryWithName name: String, countryCode: String, phoneCode: String, flag: UIImage) {
self.countryName.text = name
self.countryCode.text = countryCode
self.phoneCode.text = phoneCode
self.countryFlag.image = flag
}
}
```
## Installation
MRCountryPicker is available through Cocoapods and Carthage.
#### [CocoaPods](http://cocoapods.org):
Add the following line to your Podfile:
```ruby
pod 'MRCountryPicker', '~> 0.0.8'
```
#### [Carthage](https://github.com/Carthage/Carthage):
Add the following line to your Cartfile:
```ruby
github "xTrinch/MRCountryPicker" ~> 0.0.8
```
## Author
xtrinch, [email protected]
Made with a little help from my friends over at:
https://github.com/marmelroy/PhoneNumberKit
https://github.com/Keyflow/CountryPicker-iOS-Swift
https://github.com/nicklockwood/CountryPicker
## License
MRCountryPicker is available under the MIT license. See the LICENSE file for more info.