#18 用 slider 移動元件 & 播放動畫

目的:熟悉並實作Slider元件

拉IBOutlet

Slider Function

@IBAction func slider(_ sender: UISlider) {
let image = String(format: "animated-woman-image-0274-%02d", arguments: [Int(sender.value)])
imageView.image = UIImage(named: image)
let animateImage = UIImage.animatedImageNamed("animated-love-image-0552-", duration: 1)

if Int(sender.value) % 2 == 0 {
peterImageView.alpha = 0.5
myImageView.alpha = 1
} else {
myImageView.alpha = 0.5
peterImageView.alpha = 1
if Int(sender.value) == 27 {
sadFace.alpha = 1
gifImage.image = animateImage
}
}
}

Demo

--

--