涂鸦礼物显示多一秒

This commit is contained in:
fengshuo
2022-10-27 15:49:25 +08:00
parent 62b9a4261a
commit c52ceb1d72
2 changed files with 9 additions and 40 deletions

View File

@@ -33,8 +33,6 @@ NSString * const kYinyouPrivateKey = @"kYinyouPrivateKey";
@property (nonatomic, strong) UIButton *confirmButton;
///退
@property (nonatomic, strong) UIButton *exitButton;
///
@property (nonatomic,strong) dispatch_source_t timer;;
@end
@implementation UserPrivacyView
@@ -43,7 +41,6 @@ NSString * const kYinyouPrivateKey = @"kYinyouPrivateKey";
{
self = [super initWithFrame:frame];
if (self) {
[self startCountdown];
[self initSubViews];
[self initSubViewConstraints];
}
@@ -145,36 +142,6 @@ NSString * const kYinyouPrivateKey = @"kYinyouPrivateKey";
}
}
//
- (void)startCountdown{
__block NSInteger time = 3; //
if (self.timer != nil) {
dispatch_source_cancel(self.timer);
}
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(self.timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //
@kWeakify(self);
dispatch_source_set_event_handler(self.timer, ^{
@kStrongify(self);
if(time <= 0){ //
dispatch_source_cancel(self.timer);
dispatch_async(dispatch_get_main_queue(), ^{
self.confirmButton.userInteractionEnabled = YES;
[self.confirmButton setTitle:@"同意" forState:UIControlStateNormal];
});
}else{
dispatch_async(dispatch_get_main_queue(), ^{
self.confirmButton.userInteractionEnabled = NO;
NSString * title = [NSString stringWithFormat:@"同意(%ld)", time];
[self.confirmButton setTitle:title forState:UIControlStateNormal];
});
time--;
}
});
dispatch_resume(self.timer);
}
#pragma mark - getters and setters
- (UILabel *)titleLabel {

View File

@@ -54,13 +54,15 @@
- (void)dramGraffitiAnimationView {
if (self.index >= (self.datasource.count -1)) {
self.timer.fireDate = NSDate.distantFuture;
[self.datasource removeAllObjects];
self.index = 0;
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomGraffitiGiftAnimationViewCompletion:attachment:)]) {
[self.delegate xPRoomGraffitiGiftAnimationViewCompletion:self attachment:self.model];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.timer.fireDate = NSDate.distantFuture;
[self.datasource removeAllObjects];
self.index = 0;
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomGraffitiGiftAnimationViewCompletion:attachment:)]) {
[self.delegate xPRoomGraffitiGiftAnimationViewCompletion:self attachment:self.model];
}
});
return;
}
NSValue * valeu= [self.datasource objectAtIndex:self.index];