This is custom subclass of UIView, which indicates the progress of task in percent.
- SPWaterProgressIndicatorView_README.md
- SPWaterProgressIndicatorView.hm
- SPWaterProgressIndicatorView.swift
- WaterWaveDemo project demostrates how to use this class in Objective-C Project.
- WaterWaveDemo_Swift project demostrates how to use this class in Swift Project.
- Add SPWaterProgressIndicatorView.hm files to the project.
- There are two ways to use this class:
- Specify a
UIView
's class as SPWaterProgressIndicatorView in IB. - Using
alloc
|initWithFrame:
(Objective-C) to create and initialize an instance, then add it to aUIView
. - Using
UIView
|init(frame: CGRect)
(Swift) to create and initialize an instance, then add it to aUIView
.
- Specify a
Important to Know
- Init with
init(frame: CGRect)
- No matter what CGRect being passed to initialize it, the view will be trunked to be a square.
Objective-C
// Initialization.
- (void)viewDidLoad {
[super viewDidLoad];
self.waterView = [[SPWaterProgressIndicatorView alloc] initWithFrame:self.view.bounds];
self.waterView.center = self.view.center;
[self.view addSubview:self.waterView];
}
// Update percent
[self.waterView updateWithPercentCompletion:percent];
Swift
// Initialization
override func viewDidLoad() {
super.viewDidLoad()
self.wave = SPWaterProgressIndicatorView(frame: self.view.bounds)
self.wave.center = self.view.center;
self.view.addSubview(self.wave)
}
// Update percent
self.wave.completionInPercent = percent
1.0