Reputation: 10245
I am looking at writing some custom UITableViewCells that have a UIWebView squirted into them. I want to have a couple of icons that will appear in the html of the uiWebview, the images are stored locally on the device.
I would like to know if these are then treated like normal images when building for different devices. I.e. following the naming convention @2x.png for retina displays?
dose this translate over to uiwebviews or not?
Upvotes: 2
Views: 320
Reputation: 7386
You need to use CSS and media queries to tell the web view to display your @2x image. You then also need to set the desired size explicitly.
So, assuming you have a background image that is 25px normally and 50px @2x then you'd do something like this for a retina display:
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
.nav-bar-button-right button .button-icon {
background-image: url([email protected]);
background-size: 25px 25px;
}
}
Adjust this for your usage but that's the idea. I hope it helps.
Upvotes: 1
Reputation: 7065
A UIWebView is there to interpret and display whatever the HTML tells it to. In short the answer is NO, a webview will display the EXACT linked image to screen. I have implemented UIWebViews in apps I have developed, that display nothing more than internal HTML. What I do with these, is simply provide the 2X image and let the webview handle the sizing.
Another way to go about this would be to internally recognize (and it is possible) if you are working on a retina display and provide HTML that calls out @2x images. So you would essentially provide myhtml.html and [email protected] and perform the retina recognition yourself.
Upvotes: 2