๐ A collection of all country flags to be used in iOS apps
A collection of all country flags in PNG โ plus the sprite sheet for iOS apps and Swift class for accessing country flags by country code (ISO 3166-1 alpha-2)
Simple use case
if let flagSheet = FlagIcons.loadDefault() {
let image = flagSheet.getImageFor("PL")
// ...
}
In the example above created image is reusing a memory already allocated to store flags sheet. Image is valid as long as flagSheet
exists. Underlying UIImage
is cached and shared between calls, cache can be flushed with flagSheet?.flushCache()
call.
Use deepCopy
parameter to create copy of a flag image. Underlying bytes will be copied over to new image data
if let flagSheet = FlagIcons.loadDefault() {
let image = flagSheet.getImageFor("PL", deepCopy: true)
// ...
}
Additionaly its possible to get country names
if let countries = FlagIcons.loadCountries() {
if let country = countries.first(where: { $0.code == "PL" }) {
print(country.name) // output: Poland
}
}
This repo is used in one of my apps - Last Day? Life progress and stats
For usage example please see sample country flags application
> cd FlagIconSample
> pod install
This project wouldn't exist without the awesome flag-ison-css