国旗和国家代码

FlagAndCountryCode 为每个国家/地区提供电话代码和国旗。适用于 UIKit 和 SwiftUI

SPM Compatible Cocoapods Compatible Carthage Compatible License: MIT

用法

使用静态变量 all 获取 CountryFlagInfo 对象列表

import FlagAndCountryCode

let countries = CountryFlagInfo.all

每个 CountryFlagInfo 包含: name - 国家/地区的名称(“美国”)
code - 两位字母国家/地区代码(“US”)
dialCode - 电话区号(“+1”)
languageNative - 语言的原始名称(“Español”)
languageEnglish - 语言的英文名称(“Spanish”)

在选择的 CountryFlagInfo 上使用 getCountryImage。它具有 UIKit 和 SwiftUI 实现,分别返回 UIImageView。传递您想要的国旗样式作为参数。

country.getCountryImage(with: .roundedRect)

可用的国旗类型

roundedRect - 21 x 15,带有圆角
square - 15 x 15,带有圆角
circle - 15 x 15

示例

要尝试 FlagAndCountryCode 示例

安装

Swift Package Manager

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

CocoaPods

要安装 FlagAndCountryCode,只需将以下行添加到您的 Podfile 中

pod 'FlagAndCountryCode'

Carthage

要使用 Carthage 将 FlagAndCountryCode 集成到您的 Xcode 项目中,请在您的 Cartfile 中指定它

github "Exyte/FlagAndCountryCode"

要求

我们其他的开源 SwiftUI 库

PopupView - Toasts 和 popups 库
Grid - 最强大的 Grid 容器
ScalingHeaderScrollView - 带有粘性标题的滚动视图,滚动时标题会缩小
AnimatedTabBar - 带有多种预设动画的选项卡栏
MediaPicker - 可定制的媒体选择器
Chat - 聊天 UI 框架,具有完全可定制的消息单元格、输入视图和内置的媒体选择器
OpenAI OpenAI REST API 的 Wrapper 库
AnimatedGradient - 动画线性渐变
ConcentricOnboarding - 动画引导流程
FloatingButton - 浮动按钮菜单
ActivityIndicatorView - 一系列动画加载指示器
ProgressIndicatorView - 一系列动画进度指示器
SVGView - SVG 解析器
LiquidSwipe - 流动导航动画