Tasks with my UIImageView
I need to do the following tasks with my UIImageView.
开发者_如何学编程- 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?
for highlighting place the imageView above a UIView,but not inside it[i.e put them both on a common super view] (with a frame 2-3 pix greater than imageView) with backgroundColor as the color of ur highlight to be .. set it hidden
create button (I hope u know how to create that) and add it to the imageView. In the button click method set that imageView.image = nil
add a tapGestureRecogniser to the imageView and in the the method set the myView.hidden = NO
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).
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;
精彩评论