TSPurchasePromotionalVC+Animation.swift 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // TSPurchasePromotionalVC+Animation.swift
  3. // AIEmoji
  4. //
  5. // Created by 100Years on 2025/7/2.
  6. //
  7. import APNGKit
  8. import Delegate
  9. extension TSPurchasePromotionalVC {
  10. func creatApngImageView() -> APNGImageView {
  11. let image = try! APNGImage(named: "Gift")
  12. image.numberOfPlays = 1
  13. let apngImageView = APNGImageView(image: image)
  14. apngImageView.autoStartAnimationWhenSetImage = false
  15. apngImageView.onAllPlaysDone.delegate(on: self) { (self, _) in
  16. UIView.animate(withDuration: 0.5, animations: {
  17. self.animationView.alpha = 0
  18. self.contentView.alpha = 1
  19. }, completion: { finished in
  20. dePrint("kPurchaseCountDownTime.start")
  21. kPurchaseCountDownTime.start()
  22. self.animationView.removeFromSuperview()
  23. })
  24. }
  25. return apngImageView
  26. }
  27. static var showGift:Bool{
  28. if kPurchaseDefault.isVip == false,
  29. kPurchaseDefault.checkLocalReceiptForIntroOffer(type: .week(.weekPromotional1)) == false,
  30. kPurchaseCountDownTime.isShowGift{
  31. return true
  32. }
  33. return false
  34. }
  35. func addApngImageView(){
  36. animationView.backgroundColor = .black.withAlphaComponent(0.8)
  37. self.view.addSubview(animationView)
  38. animationView.snp.makeConstraints { make in
  39. make.edges.equalToSuperview()
  40. }
  41. animationView.addSubview(animationLab)
  42. animationLab.snp.makeConstraints { make in
  43. make.center.equalToSuperview()
  44. }
  45. animationView.addSubview(apngImageView)
  46. apngImageView.snp.makeConstraints { make in
  47. make.centerY.equalToSuperview()
  48. make.width.height.equalTo(k_ScreenWidth)
  49. }
  50. kMainShort(){
  51. self.animationLab.setNeedsLayout()
  52. self.animationLab.alpha = 1
  53. self.animationLab.applyGradient(colors: ["#FA794F".uiColor,"#F8C32A".uiColor,"#FEFBF4".uiColor])
  54. self.animationLab.alpha = 0.0
  55. kMainAfter(0.5) {
  56. self.apngImageView.startAnimating()
  57. UIView.animate(withDuration: 0.8) {
  58. self.animationLab.transform = CGAffineTransform(translationX: 0, y: -150)
  59. self.animationLab.alpha = 1
  60. }
  61. }
  62. }
  63. }
  64. }