BusyNavigationBar:实践指南

作者:袖梨 2026-09-11

真正理解BusyNavigationBar,要从它处理的任务开始:用于显示加载效果的 UINavigationBar 扩展。从日常自动化的使用方式看,输入边界、依赖和失败处理如果不清楚就很难稳定复用是采用前必须回答的问题。更实际的做法是用一项范围明确的真实任务完成最小试跑,同时核对配置时间、输出质量、异常信息和维护痕迹,不要直接在关键项目上。我会把它列入愿意先做小范围验证并复查原始文档的团队的候选清单,而不是仅凭项目介绍直接纳入生产。

BusyNavigationBar

一个 UINavigationBar 扩展,用于在导航栏背景上方显示加载效果。

截图

条纹

酒吧

您的自定义层

用途

BusyNavigationBar 可通过 CocoaPods 获得。安装 只需将以下几行添加到您的 Podfile 中:

use_frameworks!
pod "BusyNavigationBar"

或者将以下行添加到您的 Cartfile 中:

github "gmertk/BusyNavigationBar" "master"

安装完成后,您就可以使用导航栏的新方法了; start(_ options: BusyNavigationBarOptions)stop()

属性

var options = BusyNavigationBarOptions()

/**
    Animation type

    - Stripes: Sliding stripes as seen in Periscope app.
    - Bars: Bars going up and down like a wave.
    - CustomLayer(() -> CALayer): Your layer to be inserted in navigation bar. In this case, properties other than `transparentMaskEnabled` and `alpha` will not be used. 
*/
options.animationType = .Stripes

/// Color of the shapes. Defaults to gray.
options.color = UIColor.grayColor()

/// Alpha of the animation layer. Remember that there is also an additional (constant) gradient mask over the animation layer. Defaults to 0.5.
options.alpha = 0.5

/// Width of the bar. Defaults to 20.
options.barWidth = 20

/// Gap between bars. Defaults to 30.
options.gapWidth = 30

/// Speed of the animation. 1 corresponds to 0.5 sec. Defaults to 1.
options.speed = 1

/// Flag for enabling the transparent masking layer over the animation layer.
options.transparentMaskEnabled = true

// Start animation
self.navigationController?.navigationBar.start(options)

// Stop animation
self.navigationController?.navigationBar.stop()

更多

@bitwaker 有 一个很好的教程 关于 Periscope 的下拉刷新控制。

相关文章

精彩推荐