优化提交
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#import "QXHeadlineView.h"
|
||||
#import "QXUserHomePageViewController.h"
|
||||
#import "QXTimer.h"
|
||||
|
||||
@interface QXHeadlineView()
|
||||
|
||||
@@ -23,6 +24,9 @@
|
||||
@property (nonatomic,strong)UIButton *trampleBtn;
|
||||
@property (nonatomic,strong)UIButton *closeBtn;
|
||||
@property (nonatomic,assign)BOOL isSmall;
|
||||
@property (nonatomic,assign)long startTime;
|
||||
|
||||
@property (nonatomic,strong)QXTimer *timer;
|
||||
@end
|
||||
|
||||
@implementation QXHeadlineView
|
||||
@@ -166,6 +170,7 @@
|
||||
self.nameLabel.text = model.nickname;
|
||||
[self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
||||
self.contentLabel.text = model.content;
|
||||
[self startTimer];
|
||||
if (self.isSmall) {
|
||||
[UIView animateWithDuration:0.15 animations:^{
|
||||
// self.headLineBgView.width = self.width-self.iconImageView.right-6;
|
||||
@@ -178,8 +183,34 @@
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)startTimer{
|
||||
MJWeakSelf
|
||||
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970];
|
||||
// 将秒转换为毫秒
|
||||
long long milliseconds = (long long)(timeInterval);
|
||||
self.startTime = self.model.end_time.longLongValue - milliseconds;
|
||||
if (self.startTime <= 0) {
|
||||
//时间错误不进行倒计时
|
||||
[self removeFromSuperview];
|
||||
return;
|
||||
}
|
||||
[self stopTimer];
|
||||
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.startTime--;
|
||||
if (weakSelf.startTime<=0) {
|
||||
[weakSelf stopTimer];
|
||||
[weakSelf removeFromSuperview];
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
-(void)stopTimer{
|
||||
if (_timer) {
|
||||
[self->_timer invalidate];
|
||||
self->_timer= nil;
|
||||
}
|
||||
}
|
||||
-(void)handlePan:(UIPanGestureRecognizer*)recognizer{
|
||||
if (recognizer.state == UIGestureRecognizerStateEnded) {
|
||||
NSLog(@"拖动结束");
|
||||
|
||||
Reference in New Issue
Block a user