问题描述
我需要用我的 UIImageView 执行以下任务.
I need to do the following tasks with my UIImageView.
- 点击时突出显示 UIImageView.
- 在UIImageView右侧创建一个清除按钮.
- 在创建的清除按钮点击上清除UIImageView.
- 在之前清空的UIImageView中设置名为
myimage.png
的图片.
- Highlight the UIImageView on click .
- Create a clear button on right side of UIImageView.
- Clear the UIImageView on the created clear button click.
- Set image named as
myimage.png
in UIImageView which is cleared before.
任何人都可以帮我做吗?任何示例代码、应用程序或链接可供参考?
Can any one help me to do it?any sample codes,apps or links to refer?
推荐答案
如果你使用的是IB,可以设置图片的高亮状态.转到属性检查器,它是右窗格中的第四个选项.将图像复制到项目中的资源文件夹后,将突出显示"下拉菜单设置为 myImage.png.
If you are using IB, you can set the highlighted state of the image. Go to the attributes inspector, its the 4th option on the right pane. Set the 'highlighted' drop down to myImage.png after copying the image into resources folder in your project.
另外,请确保启用交互复选框(启用用户交互).
Also, make sure the checkbox for Interaction is enabled (to user interaction enabled).
现在,从底部的对象"菜单中添加一个轻击手势识别器.将其添加到您想要的 UIImageView 中.将点击手势识别器的选择器(从右窗格中的最后一个选项或通过右键单击点击手势识别器)连接到 IBAction 以处理点击手势识别器.
Now, add a tap gesture recognizer from the Objects menu in the bottom. Add it to the UIImageView you want. Connect the selector of the tap gesture recognizer (from the last option in the right pane or by right clicking on the tap gesture recognizer) to an IBAction to handle the tap gesture recognizer.
在那个动作中,你可以做任何你想做的事.比如设置一个清除按钮等.您可以使用此将图像视图设置为突出显示..
In that action, you can do whatever you want. Like setting a clear button etc. You can set the imageview to highlighted using this..
self.myImageView.highlighted = YES;
这篇关于我的 UIImageView 的任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!