Seeting a Background Image for StackViewController
jenixgnanadhas opened this issue · 4 comments
Hi All,
Im using StackViewController in one of my Projects. Currently im using "backgroundcolor" property to set the BG color of the View. Now i have a new Req in which i need to set an Image as the Background. Is it Possible using this Framework ?
I tried adding a subview to the "backgroundView" property and it is not working out. Please provide some pointers.
Thank you :)
Hi Jenix, can you give me more detail about what isn't working? Maybe a code example I could check out? I would expect that you could add a subview to the background view or use the pattern init of UIColor. https://developer.apple.com/documentation/uikit/uicolor/1621933-init
Hi @louoso
StackViewController-master.zip
Thanks for the reply :)
I have modified and attached the example code of this repo. I was able to change the BG colour using .backgroundcolor property and also pattern image works fine(But we have to add a large image to support both portrait and landscape).
Im not sure why the "backgroundview" property is not working for me. I have added a test image in this example code and created an image view with a smaller frame and added this image view as the subview of "backgroundview".
please advice if the above approach is right or if i should change something. Thanks alot :)
So in this case that property isn't exposing an existing UIView, but is giving you the option to set that property to something that will then be added and pinned to the edges.
So you would want something like this:
let imageView = ...
stackViewController.backgroundView = imageView
Best of luck.
Hi @louoso
Thanks, Thanks alot :) It Works.