chronotruck / FlagPhoneNumber

A formatted phone number UITextField with country flag picker.
Apache License 2.0
437 stars 318 forks source link

Fix 'Flag disappears sometimes from picker' issue #152

Open AhmedMohamedAllam opened 4 years ago

AhmedMohamedAllam commented 4 years ago

I fixed it by replacing flag assets by get country flag from system with country code

func getFlag(country:String) -> String { 
        let base : UInt32 = 127397
        var s = ""
        for v in country.unicodeScalars {
            s.unicodeScalars.append(UnicodeScalar(base + v.value)!)
        }
        return String(s)
    }

and the flag now is from type String so I changed the UIImageView to be UILabel and bind .text property to the new flag string. you can check the changes in this fork