gpt4 book ai didi

swift - UIImageView 动画 Playground

转载 作者:行者123 更新时间:2023-11-30 12:37:04 25 4
gpt4 key购买 nike

import UIKit
import PlaygroundSupport
import XCPlayground

//main window
let view = UIView(frame: CGRect(x:0, y: 0, width: 480, height: 320))
//array of images
let animationPictures: [UIImage] =
[
UIImage(named: "first.png")!,
UIImage(named: "second.png")!
]
var animationBkg = UIImageView()
animationBkg.animationImages = animationPictures;
animationBkg.animationDuration = 0.5
animationBkg.startAnimating()

这是我目前拥有的代码。目标是让这两个图像作为动画依次播放,但它不起作用。在我的代码预览中,它只有一个黑色方 block 。

最佳答案

let animationPictures: [UIImage] =
[
UIImage(named: "first.png")!,
UIImage(named: "second.png")!
]
//animation
var animationView = UIImageView(frame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(480), height: CGFloat(320)))
animationView.animationImages = animationPictures
animationView.animationDuration = 1.5
animationView.animationRepeatCount = 0
animationView.startAnimating()
view.addSubview(animationView)

我找到了解决我自己问题的方法。感谢您的帮助

关于swift - UIImageView 动画 Playground ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42733514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com