Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Loading images from remote URLs #69

Closed
daniel-hall opened this issue Aug 12, 2014 · 4 comments
Closed

Loading images from remote URLs #69

daniel-hall opened this issue Aug 12, 2014 · 4 comments

Comments

@daniel-hall
Copy link

Hi! Really like what you're doing with Classy, and I'm exploring its suitability for a large project I'm working on. One requirement this project has is the ability to load icons and images for styled elements from a URL, as opposed to only using resources in the app's bundle.

In Pixate / CSS, doing this works something like:

.myClass {
background-image: url("http://somewhere.com/images/icon.png");
}

Is there a similar functionality implemented or planned for Classy?

@cloudkite
Copy link
Contributor

@daniel-hall while this is not directly supported at the moment. You can achieve the same thing in classy just with a bit more boiler plate

In the classy stylesheet

MyView.myClass {
    background-image-path: "http://somewhere.com/images/icon.png"
}

Then in your code, declare the property

@interface MyView
@property (nonatomic) NSString* backgroundImagePath;
@end

Then use something like UIKit+AFNetworking to load the image by overriding cas_updateStyling

@implementation MyView 
- (void)cas_updateStyling {
    [super cas_updateStyling]
    [self.imageView setImageWithURL:[NSURL URLWithString:self.backgroundImagePath]]
}
@end

@daniel-hall
Copy link
Author

@cloudkite Ah!! I get the idea. I'll play around with that -- thank you!

@dnedrow
Copy link
Member

dnedrow commented Oct 7, 2017

@daniel-hall , can this issue be closed?

@dnedrow
Copy link
Member

dnedrow commented Oct 14, 2017

Added information to wiki how-to.

@dnedrow dnedrow closed this as completed Oct 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants