Flag And Country Code

FlagAndCountryCode provides phone codes and flags for every country. Works on UIKit and SwiftUI

Usage

Use the static variable all to get the list of CountryFlagInfo objects:

import FlagAndCountryCode

let countries = CountryFlagInfo.all

Each CountryFlagInfo contains: name - like "United States" code - 2 letter code ("US") dialCode - dial code ("+1")

Use getCountryImage on a CountryFlagInfo of choice. It has both UIKit and SwiftUI implementations, returning a UIImage and a View respectively. Pass your desired flag style as a parameter.

country.getCountryImage(with: .roundedRect)

Available flag types

roundedRect - 21 x 15 with rounded corners square - 15 x 15 with rounded corners circle - 15 x 15

Examples

To try the FlagAndCountryCode examples:

  • Clone the repo https://github.com/exyte/FlagAndCountryCode.git
  • Open Example/Example.xcodeproj
  • Try it!

Installation

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/exyte/FlagAndCountryCode.git")
]

CocoaPods

To install FlagAndCountryCode, simply add the following line to your Podfile:

pod 'FlagAndCountryCode'

Carthage

To integrate FlagAndCountryCode into your Xcode project using Carthage, specify it in your Cartfile

github "Exyte/FlagAndCountryCode"

Requirements

  • iOS 15+
  • Xcode 15+

GitHub

View Github