BGVideoGiftAnimationView.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // BGVideoGiftAnimationView.m
  3. // BuguLive
  4. //
  5. // Created by Mac on 2021/8/13.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BGVideoGiftAnimationView.h"
  9. #import "GiftModel.h"
  10. @interface BGVideoGiftAnimationView ()
  11. @property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
  12. @property (weak, nonatomic) IBOutlet UILabel *nameLabel;
  13. @end
  14. @implementation BGVideoGiftAnimationView
  15. - (void)awakeFromNib{
  16. [super awakeFromNib];
  17. self.frame = CGRectMake(kScreenW, kScreenH / 4, 186, 38);
  18. }
  19. - (void)setGiftModel:(GiftModel *)giftModel{
  20. _giftModel = giftModel;
  21. [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:giftModel.icon]];
  22. self.nameLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%@礼物送出成功"),giftModel.name];
  23. [UIView animateWithDuration:0.25 animations:^{
  24. self.frame = CGRectMake(10, self.top, self.width, self.height);
  25. } completion:^(BOOL finished) {
  26. [self performBlock:^(id selfPtr) {
  27. [UIView animateWithDuration:0.25 animations:^{
  28. self.frame = CGRectMake(-kScreenW, self.top, self.width, self.height);
  29. } completion:^(BOOL finished) {
  30. self.frame = CGRectMake(kScreenW, self.top, self.width, self.height);
  31. [self performBlock:^(id selfPtr) {
  32. if (self.delegate && [self.delegate respondsToSelector:@selector(animationView:didFinishAnimation:)]) {
  33. [self.delegate animationView:self didFinishAnimation:giftModel];
  34. }
  35. } afterDelay:1];
  36. }];
  37. } afterDelay:2];
  38. }];
  39. }
  40. @end