[ad_1]
I’m having a vector picture, downloaded from phosphor-icons:
I’ve downloaded .svg model of an icon.
Whenever you open this vector file in picture editor, you see that it has 192x192 dimensions.
Which I assume its not related in any respect on the subject of vectors recordsdata, however…
I’ve this code:
let button = UIButton(body: CGRect(x: 0, y: 0, width: 32, top: 32))
button.imageView?.contentMode = .scaleAspectFit
button.backgroundColor = .yellow
button.setImage(UIImage(named: "alien"), for: .regular)
button.setTitle(nil, for: .regular)
button.addTarget(self, motion: #selector(buttonTapped), for: .touchUpInside)
let merchandise = UIBarButtonItem(customView: button)
navigationItem.setRightBarButtonItems([item], animated: true)
Now the factor is, if I exploit this authentic svg picture(192×192), a button shrinks and it appears to be like like this:
however I do not need this button to have these dimensions, however quite these which are set with:
let button = UIButton(body: CGRect(x: 0, y: 0, width: 32, top: 32))
Now, if I am going to a picture editor, and alter the dimensions of this vector file to 22x22 (it nonetheless stays svg file), it reveals up like this:
which appears to be like how I would like.
The factor is, I believed that Xcode will generate required png file from this svg primarily based on gadget’s pixel density. So on this case, say, on newer gadgets that use @3x photographs, at compile time, trigger my button is outlined as 32x32 factors, a 96px X 96px picture might be created and used as @3x picture.
Additionally, I believed that that is going to work like described, it doesn’t matter what “dimensions” a bodily .svg file is, trigger it is a vector, and it must be up/down scaled as view dictates. The place I’m flawed with this, and methods to make this button to appears to be like the identical as from second picture, regardless of of what are precise .svg dimensions?
[ad_2]


