Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly IS the highlighted image in a UIImageView?

This question boggles my mind and I cannot find an answer. I looked all over the documentation, tried out code, and searched Google, but I can't find anything. The UIImageView in iOS programming can have an image set to it, but you can also set a highlighted image to it. What exactly is this highlighted image?

like image 575
user2228497 Avatar asked Mar 31 '13 04:03

user2228497


People also ask

What is the difference between a UIImage and a UIImageView?

UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .

What is UIImageView in Swift?

A view that displays a single image or a sequence of animated images in your interface.

How do I display an image in Xcode?

Drag and drop image onto Xcode's assets catalog. Or, click on a plus button at the very bottom of the Assets navigator view and then select “New Image Set”. After that, drag and drop an image into the newly create Image Set, placing it at appropriate 1x, 2x or 3x slot.


2 Answers

you can set two different images to an UIImageView, one to its image property, another to its highlightedImage property.

There are many cases where you want to change the state of the image (eg: a checkmark) from off to on or vice versa. in that case, instead of you setting the UIImageView's image to the appropriate one everytime, you can just say

theCheckMarkImageView.image = regularImage;//set the regular image theCheckMarkImageView.highLightedImage = highlightedImage; 

(based on your logic show it highlighted or not).

theCheckMarkImageView.highlighted = YES/NO; 

In addition to all this, do check Ethan Huang's answer about how tabelviewcell works with this property. Quite useful if you are showing different images based on cell selection.

like image 82
Nitin Alabur Avatar answered Sep 20 '22 18:09

Nitin Alabur


highlightedImage use for highlight ImageView,simple.

imageView.highlightedImage = [UIImage imageNamed:@"hightlighted.png"]; imageView.highlighted = YES; 

Don't need to waste time to search or read a lot. Objective-C is meaningful language. Just drag ImageView and make a try code, step by step test all property, method in UIImageView.h(in UIKit framework) and you'll understand. Do the same with other UI element.

like image 30
LE SANG Avatar answered Sep 23 '22 18:09

LE SANG