Int
变量来存储当前的选择。import AnimatedTabBar
AnimatedTabBar(selectedIndex: $selectedIndex) {
TabButton1()
TabButton2()
TabButton3()
}
对于第二个方法,视图必须具有相同的类型,或者手动转换为 AnyView
。
AnimatedTabBar(selectedIndex: $selectedIndex, views: [TabButton1(), TabButton2(), TabButton3()])
selectedIndex
- 绑定到当前索引
views
- 要在标签栏中显示的按钮
在弹窗修饰符中使用 customize
闭包。
barColor
- 标签栏本身的颜色
selectedColor
- 选中的标签颜色(使用模板渲染才能正确应用此颜色)
unselectedColor
- 未选中的标签颜色
ballColor
- 球形指示器颜色
verticalPadding
- 从按钮到栏顶部和底部边缘的间距
cornerRadius
- 应用于标签栏背景颜色的圆角半径
ballAnimation
- 应用于球形运动的动画曲线,默认为 .easeOut(duration: 0.6) indentAnimation
- 用于标签栏中缩进的增长/收缩的动画曲线
buttonsAnimation
- 用于将颜色应用于标签按钮的动画曲线
didSelectIndex
- 每次点击标签时都会调用的闭包
ballTrajectory
- 球形指示器动画路径的选项
parabolic
- 遵循抛物线跳到选定的按钮teleport
- 消失并快速重新出现在选定标签上方straight
- 滑动到选定的标签默认情况下,标签仅具有简单的颜色动画,但是您可以自定义它。 该库具有两种开箱即用的内置按钮类型:DropletButton
和 WiggleButton
,以及示例项目中的超级自定义 ColorButton
类型。 请随意在您的项目中使用它们或在它们的基础上构建您自己的按钮。
要尝试 AnimatedTabBar 示例
https://github.com/exyte/AnimatedTabBar.git
cd <AnimatedTabBarRepo>/Example/
pod install
以安装所有依赖项open AnimatedTabBarExample.xcworkspace/
以在 Xcode 中打开项目dependencies: [
.package(url: "https://github.com/exyte/AnimatedTabBar.git")
]
要安装 AnimatedTabBar
,只需将以下行添加到您的 Podfile 中
pod 'ExyteAnimatedTabBar'
要使用 Carthage 将 AnimatedTabBar
集成到您的 Xcode 项目中,请在您的 Cartfile
中指定它
github "Exyte/AnimatedTabBar"
非常感谢 Yeasin Arafat 的精美原创作品,我们用 SwiftUI 重新创建了它。
PopupView - Toasts 和 popups 库
Grid - 最强大的 Grid 容器
ScalingHeaderScrollView - 带有粘性标题的滚动视图,滚动时会缩小
MediaPicker - 可定制的媒体选择器
Chat - 聊天 UI 框架,具有完全可定制的消息单元格、输入视图和内置的媒体选择器
OpenAI OpenAI REST API 的 Wrapper 库
AnimatedGradient - 动画线性渐变
ConcentricOnboarding - 动画引导流程
FloatingButton - 浮动按钮菜单
ActivityIndicatorView - 多个动画加载指示器
ProgressIndicatorView - 多个动画进度指示器
FlagAndCountryCode - 每个国家/地区的电话代码和标志
SVGView - SVG 解析器
LiquidSwipe - 流体导航动画