NAKPlaybackIndicatorView.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // NAKPlaybackIndicatorView.h
  3. // PlaybackIndicator
  4. //
  5. // Created by Yuji Nakayama on 1/27/14.
  6. // Copyright (c) 2014 Yuji Nakayama. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "NAKPlaybackIndicatorViewStyle.h"
  10. /**
  11. Values for the [state]([NAKPlaybackIndicatorView state]) property.
  12. */
  13. typedef NS_ENUM(NSInteger, NAKPlaybackIndicatorViewState) {
  14. /**
  15. Stopped state of an indicator view.
  16. In this state, if an indicator's [hidesWhenStopped]([NAKPlaybackIndicatorView hidesWhenStopped]) is `YES`, the indicator becomes hidden.
  17. Or if an indicator's [hidesWhenStopped]([NAKPlaybackIndicatorView hidesWhenStopped]) is `NO`, the indicator shows idle bars.
  18. */
  19. NAKPlaybackIndicatorViewStateStopped = 0,
  20. /**
  21. Playing state of an indicator view.
  22. In this state, an indicator shows oscillatory animated bars.
  23. */
  24. NAKPlaybackIndicatorViewStatePlaying,
  25. /**
  26. Paused state of an indicator view.
  27. In this state, an indicator shows idle bars.
  28. */
  29. NAKPlaybackIndicatorViewStatePaused
  30. };
  31. /**
  32. `NAKPlaybackIndicatorView` is a view that mimics the music playback indicator in the Music.app on iOS 7.
  33. It has some vertical bars which oscillate randomly.
  34. The color of the bars can be changed by setting `tintColor` property (`UIView`) of the receiver or its ancestor view.
  35. Out of the box it works well with Auto Layout system as it provides sensible layout information
  36. such as intrinsic content size, baseline, and priorities of content hugging / compression resistence.
  37. Of course, it can work with frame-based layout system also.
  38. */
  39. @interface NAKPlaybackIndicatorView : UIView
  40. - (instancetype)initWithStyle:(NAKPlaybackIndicatorViewStyle*)style;
  41. - (instancetype)initWithFrame:(CGRect)frame style:(NAKPlaybackIndicatorViewStyle*)style NS_DESIGNATED_INITIALIZER;
  42. /**
  43. The style of the receiver.
  44. */
  45. @property (nonatomic, readonly) NAKPlaybackIndicatorViewStyle* style;
  46. /**
  47. The current state of the receiver.
  48. You can control the receiver's appearance and behavior by setting this property.
  49. - `NAKPlaybackIndicatorViewStateStopped`:
  50. - If hidesWhenStopped is `YES`, the receiver becomes hidden.
  51. - If hidesWhenStopped is `NO`, the receiver shows idle bars (same as `NAKPlaybackIndicatorViewStatePaused`).
  52. - `NAKPlaybackIndicatorViewStatePlaying`: The receiver shows oscillatory animated bars.
  53. - `NAKPlaybackIndicatorViewStatePaused`: The receiver shows idle bars.
  54. The initial value is `NAKPlaybackIndicatorViewStateStopped`.
  55. */
  56. @property (nonatomic, assign) NAKPlaybackIndicatorViewState state;
  57. /**
  58. A boolean value that controls whether the receiver is hidden
  59. when the state is set to `NAKPlaybackIndicatorViewStateStopped`.
  60. If the value of this property is `YES` (the default),
  61. the receiver sets its `hidden` property (`UIView`) to `YES`
  62. when receiver’s state is `NAKPlaybackIndicatorViewStateStopped`.
  63. If the value is `NO`, the receiver is shown even when it's stopped.
  64. Note that by setting state `NAKPlaybackIndicatorViewStatePlaying` or `NAKPlaybackIndicatorViewStatePaused`
  65. the receiver will be shown automatically.
  66. */
  67. @property (nonatomic, assign) BOOL hidesWhenStopped;
  68. @end