R.swift icon indicating copy to clipboard operation
R.swift copied to clipboard

Don't generate static resource for images with dot-suffix

Open tomlokhorst opened this issue 8 years ago • 2 comments

Apparently, UIImage(named:) strips away anything that looks like a file extension when looking up an image.

For example: If there's two images: my-icon and my-icon.selected R.swift will generate: R.image.myIcon and R.image.myIconSelected

But when trying to load UIImage(named: "my-icon.selected"), the first image (my-icon) will be returned. Only if that file isn't available, will the full image name be used.

For this reason, I think R.swift should refuse to generate myIconSelected and emit a warning in this case, since the image can't be loaded anyway.

tomlokhorst avatar Mar 13 '17 16:03 tomlokhorst

This still seems to be an unsolved problem with UIKit, right? And it's even worse now when you try to provide fallback assets for system symbols, since their names contain lots of dots. Assets are loaded or not virtually at random.

codeface-io avatar Nov 28 '19 15:11 codeface-io

let exam = UIImage(named: data.newImage, in: bundle, compatibleWith: self.traitCollection)

How can i compatibleWithTraitCollection refactor this?

aysennmt avatar May 07 '21 08:05 aysennmt