如何让图片在点击后消失?
How to make an image disappear after clicking it?
我想让一个小image.png点击后消失。
我是 swift 的新生儿,所以我在 Playground 上使用单一视图进行实验。有人可以帮帮我吗?
创建时添加此代码 your_imageView
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))
your_imageView.isUserInteractionEnabled = true
your_imageView.addGestureRecognizer(tapGestureRecognizer)
func imageTapped(tapGestureRecognizer: UITapGestureRecognizer)
{
let tappedImage = tapGestureRecognizer.view as! UIImageView
tappedImage.isHidden = true
}
我想让一个小image.png点击后消失。 我是 swift 的新生儿,所以我在 Playground 上使用单一视图进行实验。有人可以帮帮我吗?
创建时添加此代码 your_imageView
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))
your_imageView.isUserInteractionEnabled = true
your_imageView.addGestureRecognizer(tapGestureRecognizer)
func imageTapped(tapGestureRecognizer: UITapGestureRecognizer)
{
let tappedImage = tapGestureRecognizer.view as! UIImageView
tappedImage.isHidden = true
}