BogoRankHeadGifView.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // BogoRankHeadGifView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/3/29.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoRankHeadGifView.h"
  9. @implementation BogoRankHeadGifView
  10. - (instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. self.viewArr = [NSMutableArray array];
  15. [self setUpView];
  16. }
  17. return self;
  18. }
  19. -(void)setUpView{
  20. NSArray *imgArr = @[@"mg_new_rank_left",@"mg_new_rank_center",@"mg_new_rank_right"];
  21. // mg_new_rank_left
  22. CGFloat viewWidth = (kScreenW - kRealValue(12 * 2)) / 3;
  23. for (int i = 0; i < imgArr.count; i++) {
  24. UIImageView *imgView = [[UIImageView alloc]init];
  25. [imgView setImage:[UIImage imageNamed:imgArr[i]]];
  26. if (i == 0) {
  27. imgView.frame = CGRectMake(kRealValue(12), self.height, viewWidth, kRealValue(60));
  28. }else if (i == 1){
  29. imgView.frame = CGRectMake(kRealValue(12) + viewWidth * i, self.height, viewWidth, kRealValue(70));
  30. }else if (i == 2){
  31. imgView.frame = CGRectMake(kRealValue(12) + viewWidth * 2, self.height, viewWidth, kRealValue(60));
  32. }
  33. // imgView.bottom = self.height;
  34. imgView.alpha = 0;
  35. [self.viewArr addObject:imgView];
  36. [self addSubview:imgView];
  37. }
  38. for (int i = 0; i < self.viewArr.count; i ++) {
  39. UIView *view = self.viewArr[i];
  40. if (i == 1) {
  41. [UIView transitionWithView:view duration:0.3 options:UIViewAnimationOptionCurveEaseIn animations:^{
  42. view.bottom = self.height;
  43. view.alpha = 1;
  44. } completion:^(BOOL finished) {
  45. }];
  46. }else{
  47. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  48. [UIView transitionWithView:view duration:0.5 options:UIViewAnimationOptionCurveEaseIn animations:^{
  49. view.bottom = self.height;
  50. view.alpha = 1;
  51. } completion:^(BOOL finished) {
  52. }];
  53. // });
  54. }
  55. }
  56. // [UIView beginAnimations:nil context:nil];
  57. // [UIView setAnimationDelay:1];
  58. // [UIView setAnimationDuration:2];
  59. // [UIView setAnimationRepeatCount:1];
  60. // [UIView setAnimationRepeatAutoreverses: YES]; // 翻转
  61. // [UIView setAnimationCurve:UIViewAnimationCurveLinear]; //设置动画变化的曲线
  62. //// for (UIView *view in self.viewArr) {
  63. //// <#statements#>
  64. //// }
  65. // UIView *view = self.viewArr[2];
  66. //// view.alpha = 0;
  67. //// view.center = CGPointMake(view.center.x, view.center.y + 50);
  68. // view.bottom = self.height;
  69. // [UIView setAnimationDelegate:self]; // 设置代理 监测动画结束的
  70. // [UIView setAnimationDidStopSelector:@selector(shopAction)];
  71. // [UIView commitAnimations];
  72. }
  73. -(void)shopAction{
  74. NSLog(@"结束");
  75. //
  76. // for (UIView *view in self.viewArr) {
  77. // view.alpha = 1;
  78. // view.bottom = self.height;
  79. // }
  80. }
  81. @end