Color slightly different when reapplying it programmatically [duplicate] - ios

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.

Related

Adding home icon to the tab bar

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.

UITabBar first item title overlapping

I'm using tabbar with four tabs with title. I'm setting different color for selected and unselected tabs. But only for the first tab, the selected and unselected colors & title are getting overlapped. Whenever I'm selecting first tab, title is getting added again and again. I have attached screenshot as well.
In storyboard
Anyhelp could be appreciated. Thanks in advance.
You problem is most likely from the color you use for unselectedItemTintColor, which you have set to have transparency. This color should probably be solid. Try changing it to a solid version of what you want to see, like #EB989E.
Also be aware that you are setting an internal property, and as such it may change or disappear in a future release of iOS.

How do I re-use a color value throughout a storyboard

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.

Add a custom color palette to Xcode Interface Builder

My current long term project utilizes a palette of custom colors. In code, we are using a category to access these colors by name. This works great but there are times, such as when building a nib, that these colors won't be set programmatically.
I am looking for a way to define a named set of colors. For instance, when setting a background color for a UIView, I would like my drop list in Interface Builder to list my custom colors by name. Does anyone know of a way to achieve this?
Xcode 9
You now have another option to add Color Sets or Named Colors to your assets. This is new in Xcode 9.
1. Adding Named Colors to Your Project
In *.xcassets > right-click > New Color Set
2. Assigning Name Colors to Views
Your new Named Colors show up in your Color Picker now in their own section.
Custom Color Palette
In the Interface Builder's color dialog, choose the third tab. Click the gear and New to make a new custom color palette. You can name it whatever you want. Then click the plus (+) button to add a new color and name it. Use the color picker tool to set the color.
Colors from RGB or Hex
Choose the second tab in the color dialog and select RGB Sliders. This will allow you to set the colors using RGB or hex values.
More Help
XCode Tip: Color Palette
How to define colors in XCodes' Interface Builder?
How do I enter RGB values into Interface Builder?
Yes, you can create and edit a palette in IB and then share it with your team This article has all the details: http://natashatherobot.com/xcode-color-palette/
Edit:
That link has expired. You can see the web archive here: https://web.archive.org/web/20210303015055/http://natashatherobot.com/xcode-color-palette/
But, using named colors in the asset catalog is a better way to go now.

DevExpress Bar Buttons showing black and white and color when hovered?

I know it's a fat chance I'll find an answer here, but since devexpress support is a little slow I thought I'd give it a try.
Basically I'm using DevExpress 2011.1.2 beta, it's been working wonders, I love it. But I had a small issue with it recently...
I inserted an expressbar on the Delphi form and used the images from cxImageList, however, I noticed that the icons on the bar buttons were showing black and white, but when I had my mouse over, it displayed the true colors. I did not modify anything, and yes, the button is enabled.
Here's an image to better illustrate my problem:
I know the solution must be simple, however I couldn't find anything related.
Thank you.
EDIT: After modifying the button's property AutoGreyScale to false the color returned, but dull and lifeless, and when mouse is over it, more colorful.
ImageOptions of my Bar:
Set the button's AutoGrayScale property to False. You may also want to change the value of the global dxBarMakeInactiveImagesDingy variable. The TdxBarManager.Style property may also have an effect.
Also, make sure you haven't set HotImages while leaving Images unassigned.

Resources