How to set NSbutton's image to sequence frame animation

36 Views Asked by At

It is the first time to develop a Mac app by myself. I want to set a button,after clicking it, the image of the button will be displayed in the form of sequence frame animation. I set the "image button" through Storyboard, because I just started learning swift , I don't know how to solve it. When I was writing an iso app, the following code which can be used successfully, but the NSbutton does not contain the UIimage attribute, so I don't know how to solve it, thank you everyone!

UIbutton code:

@IBAction func randomBTN(_ sender: UIButton) {
let button: UIButton = sender.self
var images = [UIImage]( )
for i in  ...140 {
images.append(UIImage(named:"\( i )")!)
}

button.imageView!.animationImages = images
button.imageView!.animationDuration =2
button.imageView!.animationRepeatCount = 0
button.imageView!.startAnimating()}
0

There are 0 best solutions below