|
@@ -12,6 +12,7 @@
|
|
|
@property(nonatomic,strong)UILabel * timerlabel;
|
|
|
@property(nonatomic,assign)NSInteger second;
|
|
|
@property(nonatomic,strong)NSTimer * secondTimer;
|
|
|
+@property(nonatomic,strong)UIImageView *recordingTipImageView;
|
|
|
@end
|
|
|
|
|
|
@implementation recordingView
|
|
@@ -19,6 +20,7 @@
|
|
|
- (id)initWithFrame:(CGRect)frame{
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
|
|
+ _second = 0;
|
|
|
self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
|
|
|
[self drawAnyView];
|
|
|
|
|
@@ -61,11 +63,11 @@
|
|
|
}];
|
|
|
|
|
|
//
|
|
|
- UIImageView *recordingTipImageView = [[UIImageView alloc] init];
|
|
|
- recordingTipImageView.image = [UIImage imageNamed:@"recording_tip"];
|
|
|
- [whiteBgView addSubview:recordingTipImageView];
|
|
|
+ _recordingTipImageView = [[UIImageView alloc] init];
|
|
|
+ _recordingTipImageView.image = [UIImage imageNamed:@"recording_tip"];
|
|
|
+ [whiteBgView addSubview:_recordingTipImageView];
|
|
|
|
|
|
- [recordingTipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ [_recordingTipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.width.mas_equalTo(323.f*AUTOSCALE);
|
|
|
make.height.mas_equalTo(52.f*AUTOSCALE);
|
|
|
make.centerX.mas_equalTo(0.f);
|
|
@@ -112,19 +114,61 @@
|
|
|
//_secondTimer in
|
|
|
_secondTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerChange) userInfo:nil repeats:YES];
|
|
|
[[NSRunLoop currentRunLoop] addTimer:_secondTimer forMode:NSRunLoopCommonModes];
|
|
|
+
|
|
|
+ [self startBreathingAnimationWithImageView:_recordingTipImageView];
|
|
|
}
|
|
|
|
|
|
#pragma mark 一秒一次的timer检测
|
|
|
- (void)timerChange{
|
|
|
-
|
|
|
+ _second +=1;
|
|
|
+
|
|
|
+ KWeakSelf
|
|
|
+ mainBlock(^{
|
|
|
+ [weakSelf setTimeStringFun];
|
|
|
+ });
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 设置时间
|
|
|
+- (void)setTimeStringFun
|
|
|
+{
|
|
|
+ // 时长 totalTime
|
|
|
+ NSInteger hour = 0;
|
|
|
+ NSInteger min = 0;
|
|
|
+ NSInteger second = 0;
|
|
|
+
|
|
|
+ hour = _second / 60 /60;
|
|
|
+ min = (_second -60*hour)/60;
|
|
|
+ second = _second -60*hour - 60 *min;
|
|
|
+
|
|
|
+ NSString* totalTimeStr = [[NSString alloc] initWithFormat:@"%02ld:%02ld:%02ld",hour,min,second];
|
|
|
+ _timerlabel.text = totalTimeStr;
|
|
|
}
|
|
|
|
|
|
- (void)didClickButFun
|
|
|
{
|
|
|
+ [self stopBreathingAnimationWithImageView:_recordingTipImageView];
|
|
|
+ [_secondTimer invalidate];
|
|
|
+ _secondTimer = nil;
|
|
|
+
|
|
|
[[AudioRecorderManager sharedManager] stopRecording];
|
|
|
if (_didClickRecordEndFun) {
|
|
|
_didClickRecordEndFun();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)startBreathingAnimationWithImageView:(UIImageView *)imageView {
|
|
|
+ CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
|
|
|
+ animation.duration = 2.0;
|
|
|
+ animation.values = @[@1.0, @1.01, @1.02, @0.98, @1.0]; // 缩放值序列
|
|
|
+ animation.keyTimes = @[@0, @0.25, @0.5, @0.75, @1]; // 关键帧时间点
|
|
|
+ animation.repeatCount = HUGE_VALF;
|
|
|
+
|
|
|
+ [imageView.layer addAnimation:animation forKey:@"keyframeScale"];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)stopBreathingAnimationWithImageView:(UIImageView *)imageView
|
|
|
+{
|
|
|
+ [imageView.layer removeAllAnimations];
|
|
|
+}
|
|
|
@end
|