In order to support multiple brands, i am keeping the images and assets in bundle. Each bundle has different images and color codes based on brand. So how to fetch images and color code inside of a custom bundle.
Asked
Active
Viewed 221 times
1 Answers
0
If its syntax you are after, it here -- Load image from bundle with iOS
Specifically --
UIImage(named: <#T##String#>, in: <#T##Bundle?#>, compatibleWith: <#T##UITraitCollection?#>)
UIColor(named: <#T##String#>, in: <#T##Bundle?#>, compatibleWith: <#T##UITraitCollection?#>)
If you are concerned with the architecture --
I'd create an enum with all the Brands that you support with their corresponding Bundles as a computed property. Then I'd add simple methods to get image & colour based on brand in extensions of UIColor & UIImage (so you want have pass bundle every time). Those extension methods (returning colour & image) will use the methods mentioned above along with current Brand (assuming it's a global).
If current brand is not global then you can write a helper struct or something that has the current brand & will provide methods that return colour & image.
Pass bundle every time to the methods above.
I'd go with (1)

Harman Orsay
- 83
- 8