Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting image programmatically with a URLRequest #10

Closed
surayashivji opened this issue Oct 10, 2016 · 8 comments
Closed

Setting image programmatically with a URLRequest #10

surayashivji opened this issue Oct 10, 2016 · 8 comments

Comments

@surayashivji
Copy link

Are images able to be set without specifying the image name in the Storyboard? For some reason, when I set the image programmatically, to either an image in the project or one downloaded from the web, it doesn't work unless I specify it in the storyboard as well.

@IBOutlet weak var gradientBG: ComplimentaryGradientView!

let bg : UIImage = largeImage
self.gradientBG.image = UIImage(named: "test.png")
self.gradientBG.gradientTpye = .backgroundPrimary
self.gradientBG.gradientStartPoint = .left

This works when I set the following in Storyboard:
screen shot 2016-10-10 at 4 12 29 pm

However, because I want to generate a gradient from an image downloaded from the web, I cannot set it's filename in Storyboard.

Is there something I'm missing to be able to set a gradient on an image without specifying it's name in Storyboard?

Thank you for the fantastic project!

@gkye
Copy link
Owner

gkye commented Oct 10, 2016

Programtically setting the image should work, I'll look into this later today

@gkye
Copy link
Owner

gkye commented Oct 11, 2016

hmm strange just tested this out and everything works as it should. Could you please attach a demo project to help me better understand what exactly is going on?

@surayashivji
Copy link
Author

Hm that's strange. Yep! Attached is a demo project. In MoviesDetailViewController.swift I have a variable called gradientBG which is an IBOutlet to the ComplimentaryGradientView in the Storyboard. In the setupUI() method I set the image for the gradientBG to the image received from the AFNetworking method, setImageWith, which sets a UIImage based on a request.

Flix.zip

It runs Swift 3 & Xcode 8-- let me know if you need any more clarification on the demo.

@surayashivji
Copy link
Author

I was able to get it working for an image I have saved in my project but not for one being downloaded from the web

@gkye gkye closed this as completed in 23876b4 Oct 11, 2016
@gkye
Copy link
Owner

gkye commented Oct 11, 2016

Figured out the problem. The gradient layer wasn't being added when the image is set, I've fixed it and will update the pod soon. just pod update.
Btw noticed you're using the moviedb api, I've created a wrapper for it in swift here https://github.com/gkye/TheMovieDatabaseSwiftWrapper

@surayashivji
Copy link
Author

Great! Thanks-- I'll run pod update. Oh what a coincidence-- cool wrapper I'll check it out.

@surayashivji
Copy link
Author

Do you have a demo of this working? The image still isn't being set when I run it with the update

@gkye
Copy link
Owner

gkye commented Oct 14, 2016

hmm, strange i tested it on the project you attached it worked fine. see the attached folder
Flix.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants