按下按钮时更改图像属性
我的视图中显示了一个 UIImageView,并且已经设置了图像“image1”。
我的下面有一个按钮。
在运行时期间,我希望图像在按下按钮时更改为“图像2”,并且在释放时我希望图像再次显示“图像1”
1)我知道我必须给UIImage一个标签或其他东西,以便我可以从 xcode 访问它。 2)我知道我需要在按下时更改图像的属性 3)我需要有一个IBAction或其他东西,这样当我按下按钮时,它应该将图像的属性更改为“image2”
,但我不知道该怎么做?
有人可以帮忙吗?
i have a UIImageView displayed in my view with an image "image1" already set.
I have a button below it.
During runtime i would like the image to change to "image 2" when the button is pressed and upon release i would like the image to display "image1" again
1) I know that i have to give the UIImage a label or something so that i can access it from xcode.
2) i know that i need to change the propery of the image upon press
3) i need to have an IBAction or something so that when i press the button it should change the property of the image to "image2"
BUT i dont know how to do this?
Can someone help please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的控制器中需要一个连接到图像视图的插座,以便控制器可以找到图像视图并向其发送消息。请查看本教程和界面生成器文档。
You need an outlet in your controller that is connected to the image view, so that the controller can find and message the image view. Check out this tutorial, and the Interface Builder documentation.