涂鸦礼物显示多一秒
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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];
|
||||
|
Reference in New Issue
Block a user