Awesome
<a href="https://exyte.com/"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/exyte/media/master/common/header-dark.png"><img src="https://raw.githubusercontent.com/exyte/media/master/common/header-light.png"></picture></a>
<a href="https://exyte.com/"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/exyte/media/master/common/our-site-dark.png" width="80" height="16"><img src="https://raw.githubusercontent.com/exyte/media/master/common/our-site-light.png" width="80" height="16"></picture></a> <a href="https://twitter.com/exyteHQ"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/exyte/media/master/common/twitter-dark.png" width="74" height="16"><img src="https://raw.githubusercontent.com/exyte/media/master/common/twitter-light.png" width="74" height="16"> </picture></a> <a href="https://exyte.com/contacts"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/exyte/media/master/common/get-in-touch-dark.png" width="128" height="24" align="right"><img src="https://raw.githubusercontent.com/exyte/media/master/common/get-in-touch-light.png" width="128" height="24" align="right"></picture></a>
<table> <tbody> <tr> <td> <img src="https://github.com/exyte/FlagAndCountryCode/assets/9447630/07c4662f-9069-45d2-b8d8-5a7d7e3adeaa" /> </td> <td> <img src="https://github.com/exyte/FlagAndCountryCode/assets/9447630/3ee60227-5cbf-431b-881f-33262eb25bdd" /> </td> <td> <img src="https://github.com/exyte/FlagAndCountryCode/assets/9447630/e18f0e20-2738-410a-bfaa-69754bc86e7e" /> </td> </tr> </tbody> </table> <p><h1 align="left">Flag And Country Code</h1></p> <p><h4>FlagAndCountryCode provides phone codes and flags for every country. Works on UIKit and SwiftUI</h4></p>Usage
Use the static variable all
to get the list of CountryFlagInfo
objects:
import FlagAndCountryCode
let countries = CountryFlagInfo.all
Each CountryFlagInfo
contains:
name
- name of the country ("United States")
code
- 2 letter country code ("US")
dialCode
- dial code ("+1")
languageNative
- original name of the language ("Español")
languageEnglish
- name of the language in English ("Spanish")
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+
Our other open source SwiftUI libraries
PopupView - Toasts and popups library
Grid - The most powerful Grid container
ScalingHeaderScrollView - A scroll view with a sticky header which shrinks as you scroll
AnimatedTabBar - A tabbar with a number of preset animations
MediaPicker - Customizable media picker
Chat - Chat UI framework with fully customizable message cells, input view, and a built-in media picker
OpenAI Wrapper lib for OpenAI REST API
AnimatedGradient - Animated linear gradient
ConcentricOnboarding - Animated onboarding flow
FloatingButton - Floating button menu
ActivityIndicatorView - A number of animated loading indicators
ProgressIndicatorView - A number of animated progress indicators
SVGView - SVG parser
LiquidSwipe - Liquid navigation animation