tombenner / nui

Style iOS apps with a stylesheet, similar to CSS
MIT License
3.76k stars 459 forks source link

Dynamic image support? #88

Open WestonHanners opened 11 years ago

WestonHanners commented 11 years ago

I use a class that will return UIImages generated from CoreGraphics calls. I would like to be able to use them in my CSS somehow.

currently I can set [UIImage setImage:[ImageLib companyLogo]];

This has the benefit of being scaleable and small. Is there any way this could be implemented in NUI? Maybe @companyImage: [ImageLib companyLogo];?

christophercotton commented 11 years ago

It wouldn't be too hard for you to write your own version which replaces the NUIConverter method:

+ (UIImage*)toImageFromImageName:(NSString*)value
{
    return [UIImage imageNamed:value];
}

And just check for your special image name and then return it. I don't know how many other people would need to do the same thing though, for making it a more generic method.

filipengberg commented 11 years ago

I'm looking for something similar. My app is downloading images and saving them in the Library/Application Support folder. I would like to be able to use these images with NUI but as far as I know, UIImage imageNamed wont be able to find them there. How would I go about replacing the method above into one that uses imageWithContentsOfFile ? Method swizzling?

It would be nice if there could be a way to define in the nss file that an image resides outside of the application bundle, and NUI would then use imageWithContentsOfFile to load it instead.

rahulsingh2k10 commented 10 years ago

Did anybody get the solution for the "reekers" comment ? I am also trying to implement this in one of my project and I can't figure out if this is possible in this? Could anybody suggest me if this is possible to do. If so, how can I achieve this. Thanks.

phatmann commented 10 years ago

We could add a url function to NSS that could take a path to a local (or remote file), much like the url function in CSS. This would not be hard to do. For the function parsing code, just look at the color-related code that handles the rgb function for an example.

Worth mentioning: the rgb and the url functions really should be parsed by CoreParse and not the hand-rolled code. But that is part of a much larger task, so feel free to just use the hand-rolled approach for now. At least could factor out the "function parsing" into a separate method.