Git Product home page Git Product logo

flagicons's Introduction

FlagIcons

๐ŸŽ 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)

Installation

CocoaPods

Add below line to your Podfile:

pod 'FlagIcons'

then run below command in Terminal to install:

pod install

Note: If the above pod doesn't work, try using below pod definition in Podfile:

pod 'FlagIcons', :git => 'https://github.com/laszlotuss/FlagIcons.git'

Swift Package Manager

In Xcode, select menu File -> Swift Packages -> Add Package Dependency. Select a target, then add this link to the input field:

https://github.com/laszlotuss/FlagIcons.git

Usage

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
    }
}

Production use

Sample application

For usage example please see sample country flags application

> cd FlagIconSample
> pod install

Sample Flags App

Credits

This project wouldn't exist without the awesome flag-ison-css

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.