测试已测试 | ✓ |
语言语言 | Obj-CObjective C |
许可 | MIT |
发布上次发布 | 2017 年 8 月 |
由 Yuji Nakayama 维护。
NAKPlaybackIndicatorView 是一个模拟 iOS 中 Music.app 音乐播放指示器功能的视图。它包含一些垂直条,它们会随机振荡。
需要 iOS 8.0 或更高版本。
您可以使用 CocoaPods 立即尝试演示应用
# This will open an Xcode workspace
$ pod try NAKPlaybackIndicatorView
在打开的工作区中,选择 演示 方案并运行。
NAKPlaybackIndicatorView 通过 CocoaPods 提供,要安装它,只需在您的 Podfile
中添加以下行
pod 'NAKPlaybackIndicatorView'
然后运行 pod install
。
这里是一个基本示例
#import <NAKPlaybackIndicatorView/NAKPlaybackIndicatorView.h>
- (void)viewDidLoad
{
[super viewDidLoad];
NAKPlaybackIndicatorViewStyle *style = [NAKPlaybackIndicatorViewStyle iOS7Style];
NAKPlaybackIndicatorView *indicator = [[NAKPlaybackIndicatorView alloc] initWithStyle:style];
[self.view addSubview:indicator];
[indicator sizeToFit];
// Initially the `state` property is NAKPlaybackIndicatorViewStateStopped
// and the `hidesWhenStopped` property is YES.
// Thus, the view is hidden at this time.
// The view appears and the bars start animation.
indicator.state = NAKPlaybackIndicatorViewStatePlaying;
// The bars stop animation and become idle.
indicator.state = NAKPlaybackIndicatorViewStatePaused;
// The view becomes hidden.
indicator.state = NAKPlaybackIndicatorViewStateStopped;
}
您可以在代码和 Storyboard 中使用 NAKPlaybackIndicatorView,并且它与基于 Auto Layout 和基于 frame 的布局都很好地协作。
NAKPlaybackIndicatorView *indicator = [[NAKPlaybackIndicatorView alloc] initWithFrame:CGRectZero];
indicator.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:indicator];
// Then, add some positioning layout constraints.
// Note that normally you don't need to add sizing constraints
// since NAKPlaybackIndicatorView has an intrinsic content size.
// It will be automatically resized to fit its content.
NAKPlaybackIndicatorView *indicator = [[NAKPlaybackIndicatorView alloc] initWithFrame:CGRectZero];
[self.view addSubview:indicator];
[indicator sizeToFit]; // Resize itself to fit its content.
UIView
。NAKPlaybackIndicatorView
。UIView
。NAKPlaybackIndicatorView
。可以通过 NAKPlaybackIndicatorViewStyle
对条进行自定义。
可以通过设置视图或其父视图的 tintColor
属性(UIView
)来更改条的颜色。
通常情况下,视图可以通过以下方式自动调整大小以适应其内容:
sizeToFit
。或者如果您显式指定大小,则条将放置在视图的中心。
NAKPlaybackIndicatorView 的类参考可在 CocoaDocs.org 上找到。
版权 (c) 2014–2017 Yuji Nakayama
有关详细信息,请参阅 LICENSE.txt。