Material: What is the image size to create custom IconButton?

Created on 1 Jun 2016  路  10Comments  路  Source: CosmicMind/Material

I have tried to using custom image to create IconButton.
It seems to produce ugly button.
screen shot 2559-06-01 at 4 14 53 pm
screen shot 2559-06-01 at 4 14 57 pm

question

Most helpful comment

The image size should not be important. You can update your icon button's image view to adapt to the button's size:

iconBtn.imageView?.contentMode = .ScaleAspectFit

All 10 comments

The red one is what it should be.
The blue on is creating by using IconButton

The image size should not be important. You can update your icon button's image view to adapt to the button's size:

iconBtn.imageView?.contentMode = .ScaleAspectFit

simulator screen shot jun 1 2559 be 4 44 03 pm

Thanks man

But I think my image is too large so, I need to resize the image for using IconButton

that would be wise.

Resizing image isn't a nice idea because my project has more than a hundred images.

If creating IconButton programmatically ,it seem to be a perfect size.
If creating from Interface builder, The size will be wrong.
screen shot 2559-06-02 at 4 46 05 pm

After
contentMode = .ScaleAspectFit
screen shot 2559-06-02 at 4 51 59 pm

dear @aemgtz, from what I see, your button's insets are meddling with the size of your icons. You can change the content inset and the contentMode (.ScaleAspectFill for example) to see if you can improve the situation.

@aemgtz well essentially all icons passed to IconButton are custom. The button has no idea where the image comes from. As for the sizing, we use 24, 48, 72 for @1x, @2x, and @3x.

I am going to close this issue for now. I posted the sizes we use for buttons, and that should get you in the right direction. If you need any further help, please reopen or visit the Gitter channel. All the best!

Was this page helpful?
0 / 5 - 0 ratings