So, I successfully update the image src attribute within the UIWebView page 
using imageWithRederingMode:UIImageRederingModeAlwaysTemplate. However, the 
image appears "unrendered" with the tint color. Why? How do I get an image 
rendered in the tint color?

    UIImage *image = [controller.infoIcon.image 
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    NSString *data = [UIImagePNGRepresentation(image) 
base64EncodedStringWithOptions:nil];
    [webView stringByEvaluatingJavaScriptFromString:
        [NSString stringWithFormat:@"%@%@%@",
            @"( function() {"
            @"    var x = document.getElementById('infoIcon');"
            @"    if ( !! x ) { "
            @"        x.src = 'data:image/png;base64,", data, @"';"
            @"    }"
            @"})();"
        ]
    ];

Paul

On Sep 29, 2013, at 3:10 PM, Paul Scott <psc...@skycoast.us> wrote:

> I suppose I could try using stringByEvaluatingJavaScriptFromString: to insert 
> the raw template-rendered image data into the web page with the Data URI 
> scheme. The images are fairly small, so that seems doable, but if there's an 
> easier way, I'd choose that path.
> 
> Paul
> 
> On Sep 29, 2013, at 2:55 PM, Paul Scott <psc...@skycoast.us> wrote:
> 
>> Now, I'm wondering if there's a way to get UIWebView to apply tint color to 
>> an image URL, via some extension?
>> 
>> I would like my UIWebView-based app help — which references the app's images 
>> — to dynamically adopt the same tint color as the rest of the app, without 
>> resorting to saving the template-rendered image to disk.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to