我創造我自己的iMessage自定義應用,我只是想與2個圖像之間交換後臺發送的iMessage,因此創建動畫的錯覺。我甚至不確定這是可能的,但我正在嘗試使用下面的代碼。此代碼僅顯示收件人收到郵件時的第一個圖像。任何幫助,將不勝感激。動畫的iMessage應用圖片
func createImageForMessage() -> UIImage? {
let cupAnimation = UIImageView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
let imagesListArray = [UIImage(named: "boy_cup_1_1.png")!,UIImage(named: "boy_cup_1_7.png")!]
cupAnimation.animationImages = imagesListArray
cupAnimation.animationDuration = 10.0
cupAnimation.animationRepeatCount = 50
cupAnimation.startAnimating()
let cupBackground = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
cupBackground.addSubview(cupAnimation)
background.addSubview(cupBackground)
background.frame.origin = CGPoint(x: view.frame.size.width, y: view.frame.size.height)
view.addSubview(background)
UIGraphicsBeginImageContextWithOptions(background.frame.size, false, UIScreen.main.scale)
background.drawHierarchy(in: background.bounds, afterScreenUpdates: true)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
background.removeFromSuperview()
return image
}
你有沒有找到任何解決方案呢? – bittu