The bar item images I prepared are about 35*35
and I use the Sketch to export the [1x & 2x] size images;
(I can't insert any images for instances at here because of my zero reputation//Sorry about this!)
Then it displays a blue square :<
the function and title of Item is OK
BUT just the icons are wrong
Could someone tells me how to fix it!
Appreciate!!!
I figure it out!
There is nothing wrong with your code or setting
It's about your IMAGEs
You can just look at the apps on your phone.(almost)Any tab bar item icons are in gray.
So the Icon will just display their UN Hollow parts in gray!!
[Additionally,according to official API,they wrote like this:
By default, unselected and selected images are automatically created from the alpha values in the source images. To prevent system coloring, provide images with UIImageRenderingModeAlwaysOriginal.
]
Consequently the solution is : USE Sketch to make your instance's icon heart-part to be hollow
You need to add #3x image too.
Related
I want to implement a bar at the bottom of the screen with the home button - exactly like in Instagram or Messanger apps. I was trying to use a tab bar (https://developer.apple.com/ios/human-interface-guidelines/bars/tab-bars/)
And I would like to utilize system home icon for the tab bar button/item (https://developer.apple.com/documentation/uikit/uiapplicationshortcuticontype/1623374-home)
Is there any simple and straight forward way to set this home icon for the tab bar item?
Some icons can be selected directly from the list in the button/item properties in Xcode, but this home icon is not among them.
I also saved the png from the link above, resized it to 30x30 and added as a picture for the button/item, but it's just showing a grey rectangle.
Apple may or may not provide you with some images. In general no one uses stock images but provide their own. You should do the same.
So "Adding home icon to the tab bar" is pretty much the same as for any other tab bar item. You can add your image and/or text that represents your "home" button. Some images may already be at your disposal but others must be made/bought/stolen by you.
The image you use in tab bar item is only used as a mask and not as an explicit image. What that means is that only alpha component of the image will be taken. In your case you have a black icon on white background which from alpha perspective means you have a rectangle. You will need to remove the white background and make it transparent or use another image that already has these properties.
I am not sure for tab bar but you might also try to open your assets, select your image and then in options on the right find "Render as" and set it to "Original image". Even if this will work the results will not be as you desire (at least in most cases) due to a white background on the image.
In general this option is used to set it to "template" which means whenever you use this image on your components such as UIImageView it will use it's tint color and image alpha component instead of the actual colors from the image. It is a very useful tool but again I am not sure it will work on tab bar item.
You should stop wondering if Xcode is designed to be overcomplicated. Putting aside numerous amount of bugs (and there is really a lot of them) and it being slow (it really used to be faster) it is designed very nicely. But tab bar view controller is extremely high level component. If you don't like it the way it is then simply create your own. All you need is a bottom view with your N buttons which may be shaped any way you can possibly imagine and a container view on which you set a new view controller when one of those buttons is pressed.
One of my apps has three UIButtons on it, and they use images that I got from icons8. In the code, I change the tint color and it works fine. Whatever I set the tint color to is what color the button image becomes that color.
Today I wanted to add a fourth button to mute sound. I downloaded the images that I wanted from icons8, added the button and set it up like I have the rest of the buttons set up. The new button is not changing colors like the rest of them. I'm certain that it has to do with the image, because if I select a different image, it changes color. I also tried using the new image on one of the older buttons and it would not change color.
My question - is there anything special that needs to be done to an image to make it work with tint color?
Try setting the image to render as a template image. You can do this in your .xcasset folder selecting the image set, opening the attributes inspector and setting render as to "template image."
What I did was follow the #beyowulf instructions and on the code I just did this
yourBtn.tintColor = .white (or other color)
this worked for me
I am using storyboard to lay out my iOS app. I want to re-use some colors, and I don't want to re-enter the same hex string multiple times. What is the best way to do this?
You can drag the current color in the color picker (from the bottom left) to the list of swatches as in the screenshot:
You can also use the dropdown for picking a color to use a recent color. The list of recently used colors looks like it keeps 24 of them.
I have really weird problem with colors in interface builder. I set a color on one UI element, for example UIView, and then I want the same color on UIButton...but when I try to do so, colors are often different - I mean little bit different tone, not absolutely different color. How is this even possible ??? I've tried to use RGB sliders, and other sliders, also that color picker tool... Only thing that helps me sometimes is, when I create new UI element. Anybody had the same problem and knows what's going on ?
Interface Builder filters colors through your monitor's current color space by default. You can change this in Xcode4 IB by bringing up a Colors dialog, clicking the Sliders tab, then clicking the little dropdown button under the magnifying glass that looks like a color spectrum. This will bring up a list of available color spaces -- select Generic RGB and adjust the sliders as necessary to get the correct color.
See this question for more information, especially the comments on the accepted answer.
I solved this issue using "Device RGB" instead "Generic RGB".
See the image:
Unfortunately, fiddling with color spaces didn't work for me. What did work was editing the raw xml of the .xib (right click .xib, Open As > Source Code) and changing the RGB decimal values there.
The currently selected item in interface builder will be slightly different to its actual colour - it has a darkened mask applied to it to highlight the fact that it is selected. You need to click somewhere else in the window to unselect the item, it's real colour will then be shown. I've fallen into this trap myself.
I am trying to customize a bar button item. I dragged it in the navigation bar and I can display text and predefined identifiers.
However it does not display custom images (44x44 & 22x22 px).
Any ideas what might be wrong?
I think may be you did not give the Path Extention. It will be "10-medical.png" or other path extention instead png like jpg gif etc.