continueGift.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. //
  2. // continueGift.m
  3. // yunbaolive
  4. //
  5. // Created by 王敏欣 on 2016/11/5.
  6. // Copyright © 2016年 cat. All rights reserved.
  7. //
  8. #import "continueGift.h"
  9. #import "UIImageView+WebCache.h"
  10. #import "UIImageView+AFNetworking.h"
  11. #import "RKPaintedHeader.h"
  12. @interface RKPopView : UIView
  13. @property(nonatomic,assign)BOOL isPaintedGift;
  14. @property(nonatomic,strong)NSDictionary *giftData;
  15. @end
  16. @implementation RKPopView
  17. @end
  18. @implementation continueGift
  19. -(void)GiftPopView:(NSDictionary *)giftData andLianSong:(NSString *)liansong {
  20. _newheight = 5;
  21. _haohualiwus = liansong;
  22. NSNumber *uid = [giftData valueForKey:@"uid"];
  23. int giftid = [[giftData valueForKey:@"giftid"] intValue];
  24. NSString *nicename = [giftData valueForKey:@"nickname"];
  25. NSString *giftname = [giftData valueForKey:@"giftname"];
  26. if ([lagType isEqual:EN]) {
  27. giftname = minstr([giftData valueForKey:@"giftname_en"]);
  28. }
  29. NSString *giftcount = [NSString stringWithFormat:@"%@",[giftData valueForKey:@"giftcount"]] ;
  30. NSString *avatar = [giftData valueForKey:@"avatar"];
  31. NSString *gifticon = [giftData valueForKey:@"gifticon"];
  32. NSString *contStartStr = [NSString stringWithFormat:@"%@ ",YZMsg(@"送")];
  33. NSString *content = [NSString stringWithFormat:@"%@%@",contStartStr,giftname];
  34. RKPopView * GiftPopView = [[RKPopView alloc] init];//礼物
  35. GiftPopView.giftData = giftData;
  36. CFGradientLabel *labGiftNum = [[CFGradientLabel alloc] init];//礼物数量
  37. int tagID = [uid intValue]+60000+giftid + [minstr([giftData valueForKey:@"giftcount"]) intValue];
  38. labGiftNum.tag = [uid intValue]+60000+giftid + [minstr([giftData valueForKey:@"giftcount"]) intValue];
  39. int height = 66;
  40. int width = 270;
  41. int x = 5;
  42. int flag = 0;
  43. if (_popListItem1!=0) {
  44. if (_popListItem1 == tagID && _previousGiftID1 == [giftData valueForKey:@"giftid"]) {
  45. _popShowTime1=3;
  46. [self GiftNumAdd:tagID];
  47. flag = 1;
  48. //NSLog(@"rk=======1----");
  49. }else if(_popListItem1 == tagID && _previousGiftID1 != [giftData valueForKey:@"giftid"]) {
  50. //NSLog(@"rk=======1");
  51. [_GiftqueueArray addObject:giftData];
  52. [self startGiftTimer];
  53. flag = 1;
  54. }
  55. }
  56. if (_popListItem2!=0) {
  57. if (_popListItem2 == tagID && _previousGiftID2 == [giftData valueForKey:@"giftid"]) {
  58. _popShowTime2 = 3;
  59. [self GiftNumAdd:tagID];
  60. flag = 1;
  61. } else if(_popListItem2 == tagID && _previousGiftID1 != [giftData valueForKey:@"giftid"]) {
  62. //NSLog(@"rk=======2");
  63. //如果换了礼物则替换礼物
  64. [_GiftqueueArray addObject:giftData];
  65. [self startGiftTimer];
  66. flag = 1;
  67. }
  68. }
  69. if (_isPaintedShowing && [minstr([giftData valueForKey:@"type"]) isEqual:@"2"]) {
  70. //手绘礼物不能连送 展示时间由个数决定,,因此这里_popShowTime1、_popShowTime2置为-1即可
  71. _popShowTime1 = -1;
  72. _popShowTime2 = -1;
  73. //NSLog(@"rk=======3=====%d",_GiftPosition);
  74. [_GiftqueueArray addObject:giftData];
  75. [self startGiftTimer];
  76. flag = 1;
  77. }
  78. if (flag == 1) {
  79. return;
  80. }
  81. int y = 0;
  82. if (_GiftPosition ==0) {//全空显示在第一
  83. y = _newheight;
  84. _GiftPosition = 1;
  85. _popListItem1 = (int)labGiftNum.tag;
  86. _previousGiftID1 = [giftData valueForKey:@"giftid"];
  87. }else if(_GiftPosition ==1) {//一位有显示在二
  88. y = _newheight+height+5;
  89. _GiftPosition = 3;
  90. _popListItem2 = (int)labGiftNum.tag;
  91. _previousGiftID2 = [giftData valueForKey:@"giftid"];
  92. }else if (_GiftPosition == 2) {//二为有显示在一
  93. y = _newheight;
  94. _GiftPosition = 3;
  95. _popListItem1 = (int)labGiftNum.tag;
  96. _previousGiftID1 = [giftData valueForKey:@"giftid"];
  97. }else {//全有执行队列
  98. y = 0;
  99. }
  100. if(y==0) {//当前位置已满,启动队列
  101. //NSLog(@"rk=======4");
  102. [_GiftqueueArray addObject:giftData];
  103. [self startGiftTimer];
  104. return;
  105. }
  106. //gifttpy 只能在这里赋值 在之前使用 [giftData valueForKey:@"type"]
  107. NSString *giftType = minstr([giftData valueForKey:@"type"]);
  108. if ([giftType isEqual:@"2"]) {
  109. GiftPopView.isPaintedGift = YES;
  110. _isPaintedShowing = YES;
  111. if (self.rkPaintedEvent) {
  112. self.rkPaintedEvent(giftData);
  113. }
  114. }
  115. [self addSubview:GiftPopView];
  116. [GiftPopView mas_makeConstraints:^(MASConstraintMaker *make) {
  117. make.left.equalTo(self).offset(x);
  118. make.top.equalTo(self).offset(y);
  119. make.height.mas_equalTo(height);
  120. make.width.mas_equalTo(width);
  121. }];
  122. UIImageView *animationImgView = [[UIImageView alloc]init];
  123. animationImgView.image = [UIImage imageNamed:@"gift_anima1"];
  124. [GiftPopView addSubview:animationImgView];
  125. [animationImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.left.equalTo(GiftPopView).offset(-270);
  127. make.top.equalTo(GiftPopView);
  128. make.height.mas_equalTo(66);
  129. make.width.mas_equalTo(width);
  130. }];
  131. GiftPopView.backgroundColor = [UIColor clearColor];
  132. //pop背景图
  133. UIImageView *giftBGView = [[UIImageView alloc] init];
  134. giftBGView.image = [UIImage imageNamed:@"giftBG"];
  135. giftBGView.contentMode = UIViewContentModeScaleAspectFill;
  136. [GiftPopView addSubview:giftBGView];
  137. [giftBGView mas_makeConstraints:^(MASConstraintMaker *make) {
  138. make.left.equalTo(GiftPopView);
  139. make.top.equalTo(GiftPopView);
  140. make.height.mas_equalTo(66);
  141. make.width.mas_equalTo(width);
  142. }];
  143. //用户 显示头像
  144. UIImage *headerImg = [UIImage imageNamed:@"bg1"];
  145. UIImageView *headerView = [[UIImageView alloc] init];
  146. [headerView sd_setImageWithURL:[NSURL URLWithString:avatar] placeholderImage:headerImg];
  147. headerView.layer.masksToBounds = YES;
  148. [headerView.layer setCornerRadius:20];
  149. [giftBGView addSubview:headerView];
  150. [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
  151. make.left.equalTo(giftBGView).offset(7);
  152. make.top.equalTo(giftBGView).offset(13);
  153. make.height.width.mas_equalTo(40);
  154. }];
  155. //礼物名称
  156. UILabel *labName = [[UILabel alloc] init];
  157. labName.text = nicename;
  158. labName.font = SYS_Font(15);
  159. labName.textColor = [UIColor whiteColor];
  160. [giftBGView addSubview:labName];
  161. [labName mas_makeConstraints:^(MASConstraintMaker *make) {
  162. make.left.equalTo(headerView.mas_right).offset(5);
  163. make.top.equalTo(headerView).offset(3);
  164. make.height.mas_equalTo(19);
  165. make.width.mas_lessThanOrEqualTo(105);
  166. }];
  167. //礼物信息
  168. UILabel *labContent = [[UILabel alloc] init];
  169. labContent.textColor = [UIColor whiteColor];
  170. labContent.tag = tagID+68959;
  171. labContent.font = SYS_Font(15);
  172. NSMutableAttributedString *contentStr = [[NSMutableAttributedString alloc] initWithString:content];
  173. NSString *gdy_r_name = minstr([giftData valueForKey:@"giftname"]);
  174. if ([lagType isEqual:EN]) {
  175. gdy_r_name = minstr([giftData valueForKey:@"giftname_en"]);
  176. }
  177. NSRange redRange = NSMakeRange(contStartStr.length, gdy_r_name.length);
  178. [contentStr addAttributes:@{NSForegroundColorAttributeName:RGB_COLOR(@"#FFDD00", 1),NSFontAttributeName:[UIFont systemFontOfSize:14]} range:redRange];
  179. [labContent setAttributedText:contentStr];
  180. [giftBGView addSubview:labContent];
  181. [labContent mas_makeConstraints:^(MASConstraintMaker *make) {
  182. make.left.equalTo(headerView.mas_right).offset(5);
  183. make.top.equalTo(labName.mas_bottom);
  184. make.height.mas_equalTo(15);
  185. }];
  186. //礼物图片
  187. UIImageView *giftImage = [[UIImageView alloc] init];
  188. NSURL *giftImageURL = [NSURL URLWithString:gifticon];
  189. giftImage.tag = [uid intValue]+20000+giftid + [minstr([giftData valueForKey:@"giftcount"]) intValue];
  190. if ([giftType isEqual:@"2"]) {
  191. giftImage.image = [UIImage imageNamed:getImagename(@"手绘-涂鸦")];
  192. }else {
  193. [giftImage sd_setImageWithURL:giftImageURL];
  194. }
  195. [giftBGView addSubview:giftImage];
  196. [giftImage mas_makeConstraints:^(MASConstraintMaker *make) {
  197. make.left.greaterThanOrEqualTo(labName.mas_right).offset(3);
  198. make.left.greaterThanOrEqualTo(labContent.mas_right).offset(5);
  199. //make.top.equalTo(giftBGView).offset(-15);
  200. make.centerY.equalTo(giftBGView);
  201. make.height.width.mas_equalTo(40);
  202. }];
  203. CGAffineTransform matrix = CGAffineTransformMake(1, 0, tanf(-8 * (CGFloat)M_PI / 180), 1, 0, 0);
  204. UILabel *numL = [[UILabel alloc]init];
  205. numL.font = [UIFont boldSystemFontOfSize:15];
  206. numL.textColor = RGB_COLOR(@"#FFDD00", 1);
  207. [giftBGView addSubview:numL];
  208. [numL mas_makeConstraints:^(MASConstraintMaker *make) {
  209. make.top.height.equalTo(labName).offset(-2);
  210. make.left.equalTo(giftImage.mas_right).offset(8);
  211. }];
  212. CFGradientLabel *giftXL = [[CFGradientLabel alloc] init];
  213. giftXL.outLinetextColor = RGB_COLOR(@"#bd6d26", 1);
  214. giftXL.outLineWidth = 1.5;
  215. giftXL.font = [UIFont boldSystemFontOfSize:15];
  216. giftXL.labelTextColor = RGB_COLOR(@"#FFDD00", 1);
  217. giftXL.transform = matrix;
  218. [giftBGView addSubview:giftXL];
  219. [giftXL mas_makeConstraints:^(MASConstraintMaker *make) {
  220. make.left.equalTo(numL.mas_left);
  221. make.top.equalTo(labContent).offset(-2);
  222. make.height.mas_equalTo(20);
  223. }];
  224. if ([giftType isEqual:@"0"]) {
  225. if ([giftcount isEqual:@"1"]) {
  226. numL.text = @"";
  227. giftXL.text = @"X";
  228. }else{
  229. numL.text = [NSString stringWithFormat:@"x%@",giftcount];
  230. giftXL.text = [NSString stringWithFormat:@"%@ X",YZMsg(@"连送")];
  231. }
  232. }else {
  233. numL.text = [NSString stringWithFormat:@"x%@",giftcount];
  234. giftXL.text = @"";
  235. }
  236. //礼物数量
  237. labGiftNum.outLinetextColor = RGB_COLOR(@"#bd6d26", 1);
  238. labGiftNum.outLineWidth = 2;
  239. labGiftNum.text = @"1";
  240. labGiftNum.font = [UIFont boldSystemFontOfSize:40];
  241. labGiftNum.labelTextColor = RGB_COLOR(@"#FFDD00", 1);
  242. //labGiftNum.colors = @[(id)RGB_COLOR(@"#ffa800", 1).CGColor ,(id)RGB_COLOR(@"#ffe400", 1).CGColor];
  243. labGiftNum.transform = matrix;
  244. [giftBGView addSubview:labGiftNum];
  245. [labGiftNum mas_makeConstraints:^(MASConstraintMaker *make) {
  246. make.left.equalTo(giftXL.mas_right).offset(8);
  247. make.centerY.equalTo(giftBGView.mas_centerY);
  248. }];
  249. labGiftNum.hidden = NO;
  250. if ([giftType isEqual:@"2"]) {
  251. labGiftNum.hidden = YES;
  252. }
  253. [self layoutIfNeeded];
  254. [UIView animateWithDuration:0.2 animations:^{
  255. [animationImgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  256. make.left.equalTo(self).offset(x);
  257. make.top.equalTo(self).offset(y);
  258. make.height.mas_equalTo(height);
  259. make.width.mas_equalTo(width);
  260. }];
  261. [GiftPopView layoutIfNeeded];
  262. [self layoutIfNeeded];
  263. } completion:^(BOOL finished) {
  264. animationImgView.image = [UIImage imageNamed:@"gift_anima2"];
  265. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  266. [animationImgView removeFromSuperview];
  267. });
  268. }];
  269. if(_GiftPosition == 1) {
  270. CGFloat showTime = 3.0;
  271. if ([giftType isEqual:@"2"]) {
  272. showTime = [minstr([giftData valueForKey:@"giftcount"]) floatValue] *PaintedPerTime*0.75;//每个0.3秒计算
  273. }
  274. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(showTime * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
  275. [self performSelectorOnMainThread:@selector(hideGiftPop1:) withObject:GiftPopView waitUntilDone:NO];
  276. });
  277. }else {
  278. CGFloat showTime = 3.0;
  279. if ([giftType isEqual:@"2"]) {
  280. showTime = [minstr([giftData valueForKey:@"giftcount"]) floatValue] *PaintedPerTime*0.75;//每个0.3秒计算
  281. }
  282. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(showTime * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
  283. [self performSelectorOnMainThread:@selector(hideGiftPop2:) withObject:GiftPopView waitUntilDone:NO];
  284. });
  285. }
  286. }
  287. -(void)startGiftTimer {
  288. if (_GiftqueueTIME==nil) {
  289. _GiftqueueTIME = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(EnGiftqueue) userInfo:nil repeats:YES];
  290. }
  291. }
  292. /*
  293. -(int)returnGiftPos:(int)height {
  294. int y = 0;
  295. if (_GiftPosition ==0) { //全空显示在第一
  296. y = _newheight;
  297. _GiftPosition = 1;
  298. } else if(_GiftPosition ==1){ //一位有显示在二
  299. y = _newheight+height+5;
  300. _GiftPosition = 3;
  301. }
  302. else if (_GiftPosition == 2){ //二为有显示在一
  303. y = _newheight;
  304. _GiftPosition = 3;
  305. }else { //全有执行队列
  306. y = 0;
  307. }
  308. return y;
  309. }
  310. */
  311. -(void)hideGiftPop2:(RKPopView *)agr {
  312. RKPopView *GiftPopView = agr;
  313. int height = 66;
  314. int width = 270;
  315. if (_popListItem2 != 0) {
  316. //判断显示时间 如果显示时间大于0则继续递归 否则 让其消失
  317. if (_popShowTime2 >0) {
  318. _popShowTime2 -= 0.5;
  319. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
  320. [self performSelectorOnMainThread:@selector(hideGiftPop2:) withObject:GiftPopView waitUntilDone:NO];
  321. });
  322. }else {
  323. [UIView animateWithDuration:0.8 animations:^{
  324. GiftPopView.frame = CGRectMake(GiftPopView.frame.origin.x, GiftPopView.frame.origin.y-25, width, height);
  325. GiftPopView.alpha = 0;
  326. if (GiftPopView.frame.origin.y<= _newheight) {
  327. //移除一级弹出
  328. _popListItem1 = 0;
  329. if(_GiftPosition == 3){
  330. //如果现在上下都有则设置成仅下有
  331. _GiftPosition = 2;
  332. }else {
  333. //否则设置成全无
  334. _GiftPosition = 0;
  335. }
  336. } else {
  337. _popListItem2 = 0;
  338. //移除二级弹出
  339. if(_GiftPosition == 3){
  340. //如果现在上下都有则设置成仅上有
  341. _GiftPosition = 1;
  342. }else {
  343. //否则设置成全无
  344. _GiftPosition = 0;
  345. }
  346. }
  347. }];
  348. //0.8秒后删除视图
  349. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
  350. [self performSelectorOnMainThread:@selector(removeGiftPop:) withObject:GiftPopView waitUntilDone:NO];
  351. });
  352. }
  353. return;
  354. }
  355. [UIView animateWithDuration:0.8 animations:^{
  356. GiftPopView.frame = CGRectMake(GiftPopView.frame.origin.x, GiftPopView.frame.origin.y-25, width, height);
  357. GiftPopView.alpha = 0;
  358. if (GiftPopView.frame.origin.y<= _newheight) {
  359. //移除一级弹出
  360. _popListItem1 = 0;
  361. if(_GiftPosition == 3){
  362. //如果现在上下都有则设置成仅下有
  363. _GiftPosition = 2;
  364. }else {
  365. //否则设置成全无
  366. _GiftPosition = 0;
  367. }
  368. }else {
  369. _popListItem2 = 0;
  370. //移除二级弹出
  371. if(_GiftPosition == 3){
  372. //如果现在上下都有则设置成仅上有
  373. _GiftPosition = 1;
  374. }else {
  375. //否则设置成全无
  376. _GiftPosition = 0;
  377. }
  378. }
  379. }];
  380. //0.8秒后删除视图
  381. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
  382. [self performSelectorOnMainThread:@selector(removeGiftPop:) withObject:GiftPopView waitUntilDone:NO];
  383. });
  384. }
  385. -(void)hideGiftPop1:(RKPopView *)agr {
  386. RKPopView *GiftPopView = agr;
  387. int height = 66;
  388. int width = 270;
  389. if (_popListItem1 != 0) {
  390. //判断显示时间 如果显示时间大于0则继续递归 否则 让其消失
  391. if (_popShowTime1 >0) {
  392. _popShowTime1 -= 1;
  393. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
  394. [self performSelectorOnMainThread:@selector(hideGiftPop1:) withObject:GiftPopView waitUntilDone:NO];
  395. });
  396. }else {
  397. [UIView animateWithDuration:0.8 animations:^{
  398. GiftPopView.frame = CGRectMake(GiftPopView.frame.origin.x, GiftPopView.frame.origin.y-25, width, height);
  399. GiftPopView.alpha = 0;
  400. if (GiftPopView.frame.origin.y<= _newheight) {
  401. //移除一级弹出
  402. _popListItem1 = 0;
  403. if(_GiftPosition == 3){
  404. //如果现在上下都有则设置成仅下有
  405. _GiftPosition = 2;
  406. }else {
  407. //否则设置成全无
  408. _GiftPosition = 0;
  409. }
  410. }else {
  411. _popListItem2 = 0;
  412. //移除二级弹出
  413. if(_GiftPosition == 3){
  414. //如果现在上下都有则设置成仅上有
  415. _GiftPosition = 1;
  416. }else{
  417. //否则设置成全无
  418. _GiftPosition = 0;
  419. }
  420. }
  421. }];
  422. //0.8秒后删除视图
  423. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
  424. [self performSelectorOnMainThread:@selector(removeGiftPop:) withObject:GiftPopView waitUntilDone:NO];
  425. });
  426. }
  427. return;
  428. }
  429. [UIView animateWithDuration:0.8 animations:^{
  430. GiftPopView.frame = CGRectMake(GiftPopView.frame.origin.x, GiftPopView.frame.origin.y-25, width, height);
  431. GiftPopView.alpha = 0;
  432. if (GiftPopView.frame.origin.y<= _newheight) {
  433. //移除一级弹出
  434. _popListItem1 = 0;
  435. if(_GiftPosition == 3){
  436. //如果现在上下都有则设置成仅下有
  437. _GiftPosition = 2;
  438. }else{
  439. //否则设置成全无
  440. _GiftPosition = 0;
  441. }
  442. }else{
  443. _popListItem2 = 0;
  444. //移除二级弹出
  445. if(_GiftPosition == 3){
  446. //如果现在上下都有则设置成仅上有
  447. _GiftPosition = 1;
  448. }else {
  449. //否则设置成全无
  450. _GiftPosition = 0;
  451. }
  452. }
  453. }];
  454. //0.8秒后删除视图
  455. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
  456. [self performSelectorOnMainThread:@selector(removeGiftPop:) withObject:GiftPopView waitUntilDone:NO];
  457. });
  458. }
  459. -(void)removeGiftPop:(RKPopView *)viewa{
  460. if (viewa.isPaintedGift) {
  461. _isPaintedShowing = NO;
  462. }
  463. [viewa removeFromSuperview];
  464. viewa=nil;
  465. NSLog(@"礼物送完了");
  466. }
  467. //礼物队列
  468. -(void)EnGiftqueue{
  469. NSLog(@"当前队列个数:%lu",(unsigned long)_GiftqueueArray.count);
  470. if (_GiftqueueArray.count == 0 || _GiftqueueArray == nil) {//判断队列中有item且不是满屏
  471. [_GiftqueueTIME invalidate];
  472. _GiftqueueTIME = nil;
  473. return;
  474. }
  475. NSDictionary *Dic = [_GiftqueueArray firstObject];
  476. [_GiftqueueArray removeObjectAtIndex:0];
  477. [self GiftPopView:Dic andLianSong:_haohualiwus];
  478. }
  479. //添加礼物数量
  480. -(void)GiftNumAdd:(int)tag {
  481. __weak CFGradientLabel *labGiftNum = (CFGradientLabel *)[self viewWithTag:tag];
  482. int oldnum = [labGiftNum.text intValue];
  483. int newnum = oldnum +1;
  484. labGiftNum.text = [NSString stringWithFormat:@"%d",newnum];
  485. if(labGiftNum == nil){
  486. return;
  487. }
  488. CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
  489. //速度控制函数,控制动画运行的节奏
  490. animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  491. animation.duration = 0.2; //执行时间
  492. animation.repeatCount = 1; //执行次数
  493. animation.autoreverses = YES; //完成动画后会回到执行动画之前的状态
  494. animation.fromValue = [NSNumber numberWithFloat:1.5]; //初始伸缩倍数
  495. animation.toValue = [NSNumber numberWithFloat:0.8]; //结束伸缩倍数
  496. [labGiftNum.layer addAnimation:animation forKey:nil];
  497. }
  498. -(void)stopTimerAndArray{
  499. _GiftqueueArray = nil;
  500. _GiftqueueArray = [NSMutableArray array];
  501. [_GiftqueueTIME invalidate];
  502. _GiftqueueTIME = nil;
  503. _isPaintedShowing = NO;
  504. }
  505. -(void)initGift{
  506. _isPaintedShowing = NO;
  507. _GiftPosition = 0;
  508. _popListItem1 = 0;
  509. _popListItem2 = 0;
  510. _previousGiftID1 = 0;
  511. _previousGiftID1 = 0;
  512. _GiftqueueArray = [[NSMutableArray alloc] init];
  513. }
  514. @end