Reputation: 3345
I am working in an application in that I need to record and play audio file. I have done everything related to recording and playing. This time I am little confused about UI related, May be first time this confusion..
As per the above Image I need to show the playback track, so far I have done lot with progress bar and slider to show playback seconds or server response. I am checking my self to implemente this but I am not getting any exact idea to do. Can some suggest me any idea to implement the same. Your suggestions more useful for my work. Thanks in advance.
Upvotes: 0
Views: 247
Reputation: 47241
You could use the class I posted below and use it inbetween the background image and top it with the pause/play button. For the asset(little ring) at the current position you may want to use basic trigonometry.
A simple UIView subclass that draws a ring depending on a progress. It's may need some love by means of configuration of the circle radius and such:
CircleProgressView.h
@interface CircleProgressView : UIView
{
double progress_;
UIColor *color_;
}
- (void)setProgress:(float)progress;
- (void)setColor:(UIColor *)color;
@end
CircleProgressView.m
@implementation CircleProgressView
- (void)setProgress:(float)progress
{
_progress_ = progress;
[self setNeedsDisplay];
}
- (void)setColor:(UIColor *)color
{
color_ = color;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 6);
CGContextSetStrokeColorWithColor(context, color_.CGColor);
CGContextAddArc(context,
self.frame.size.width / 2.0,
self.frame.size.height / 2.0,
self.frame.size.width / 2 - 4.5, 0.0, M_PI * progress_ * 2.0, NO);
CGContextStrokePath(context);
}
Upvotes: 1