4

Just added PDF icon to my app and tried to place it in as a tab bar icon. The icon is enormous! I have selected Scales: Singe Scale in the Image Set. Here is image from the storyboard: https://i.stack.imgur.com/OhkNC.jpg

How to make it fit the bar?

Additional screenshot: https://i.stack.imgur.com/ZuDjJ.jpg

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Andrey Tsarev
  • 769
  • 1
  • 8
  • 25

3 Answers3

3

Andrey, see this link: https://stackoverflow.com/a/25818846/966789

(2014) You cannot choose a new size for the image; it will only look good if you keep it at the 44x44 size. The reason is that full vector support is not implemented ... Why it (probably) works this way: (1) This makes it backwards compatible with previous iOS versions. (2) Resizing vectors may be a computational intensive task at runtime; by implementing it this way, there are no performance hits.

This is discussed in 2014 WWDC Session 411 - "What's New in Interface Builder" at time 44:13. Note that they say the rasterization is done at build time. Also interestingly on the MAC it will use vectors at runtime. At some distant point in the future hopefully iOS will too.

Community
  • 1
  • 1
Alexander Lubyagin
  • 1,346
  • 1
  • 16
  • 30
0

Your image is 750 x 1100 or something along those lines. Have you tried using a 30 x 30 image or something small like that. I believe tab bar icons have to be around 30 x 30 px. This Icons Size Reference Chart might help ...

You should be able to edit the PDF image down to a smaller size so that you can use it as a tab bar icon.

Fahim
  • 3,466
  • 1
  • 12
  • 18
  • pdf is like svg, as long as i know. This means that it could be rendered in 200000x200000 or 30x30 with no quality loss. I really want to use vector image, but if it doesn't work i'm gonna use a standard png image – Andrey Tsarev Apr 09 '17 at 05:36
  • I realize that that's how it's "supposed" to work but I've had all sorts of trouble trying to use PDF icons. So I basically go with specific sized images with 1x, 2x, and 3x versions now - it's much simpler that way :) – Fahim Apr 09 '17 at 05:43
  • Turns out PDF images have resolutions too. Using an online convertor(not gonna mention names) you can set the pdf size. Please edit you answer so I can accept it. – Andrey Tsarev Apr 09 '17 at 06:56
  • I edited my answer to include the fact that you can resize the PDF image. Was that what you were looking for? – Fahim Apr 09 '17 at 07:02
0

One way to go about this, is to create a barbuttonItem with a custom view in which you have a uiview containing an imageview with the desired size constraints and centered position. Obviously contentmode should be scaleAspectFit.

Bjørn Ruthberg
  • 336
  • 1
  • 15