Tint Color fading when popover displayed - ios

I have a simple block of code wherein I am setting the tint color of a UIView. Under normal condition, this works well, but when I present a popover from somewhere, the rgb tint color fades to grayscale colors.
Once the popover is dismissed, the colors return to their normal values.
The code runs something like this:
UIView *view = self.imageViews[index];
view.tintColor = tintColor;
Is there a way to stop these colors from fading under presence of popover ?
Thanks in advance.

UIView has a property called tintAdjustmentMode. Did you try that out ??
A single line code like
view.tintAdjustmentMode = UIViewTintAdjustmentModeNormal;
could help you out in this case.
Edit: Swift 4.2 update:
view.tintAdjustmentMode = .normal

Related

how to make visible other components in transparent UIVIEW in swift 5

I have used a UIVIEW . I want to make transparent the UIVIEW. But when I want to chage alpha 0.0 from storyboard for make UIVIEW transparent, textfield, label and other component also transparent. I want to make transparent UIVIEW, not other component of the view. Here is the image
Please help me to make visible other components in UIVIEW transparent
Set your UIView's backgroundColor to UIColor.clear.
Instead of changing the alpha of the UIView, you can make the background color of your UIView as white with alpha component 0.5 or something
myView.backgroundColor = UIColor.black.withAlphaComponent(0.5)
If you want it to be completely transparent, you can set backgroundColor to clear from storyboard as well as code.
myView.backgroundColor = .clear
You just need to change the transparency not of the UIView itself, but of its
background color.
For example:
I set the color of the UIView transparent, while the UILabel remained its settings.
In order to create a semi transparent color, you can use the following code:
yourView.backgroundColor = UIColor.white.withAlphaComponent(0.5)
Hope this will help you!
Go to Main.Storyboard and select the view you want to make transparent.
From the Attribute Inspector select background color as custom.
Then set your desired color and decrease the percentage of Opacity of the color.

Why is the background of my table view grey when there are no rows?

Why is the background of my table view grey when there are no rows? I can't see where this is set in storyboard
Even setting the background to white explicitly I still get a grey background
Using the defaults for background also results in this grey background:
this might be due to two reason
a) you haven't set data source and delegate and your main view background color is gray
b) cell background color is gray, set that to clear color
Please add this code viewdidload or viewwillappear method
table.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
For me it looks like it is a problem of the UITableViewCells, you should set them to
self.backgroundColor = [UIColor whiteColor]; // or clearColor
then also set the UITableView itself inside the controller to backgroundColor white or grey.
Also the snippet of #Rohitsuvagiya can help to let dissappear the separators if there is no additional UITableViewCell.
Please add line your code in viewdidload or viewillappear
table.backgroundColor=[UIColor clearColor];

alpha for background color not working in iOS

Do you have any idea why alpha parameter does not work on my view ?
self.view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.4)
please also check this video
Video
thanks
If you are using storyboard and present view controller using segue, the presentation attribute of segue that show you view controller with transparent background should be over full screen as shown in attachment.
Then in your view controller set the background color by using this :
self.view.backgroundColor = UIColor(white: 0, alpha: 0.4)
It's not strange, it's behaving exactly as it should. Although many of UIColor's methods are class methods, there are still a few instance methods, and this is one of them. From the UIColor documentation .
colorWithAlphaComponent:
Creates and returns a color object that has the same color space and
component values as the receiver, but has the specified alpha
component. So, colorWithAlphaComponent: just changes the alpha value
of its receiver. Example:
let black = UIColor.blackColor() // 1.0 alpha
self.view.backgroundColor = black.colorWithAlphaComponent(0.5) // 0.5 alpha
I found an issue on iOS 12 which is related to the title (but not the answers though) where withAlphaComponent does not work.
In a storyboard, set a view background colour to an opaque named colour
In the code (viewDidLoad of the viewController for instance), change the background colour of this view to the same named colour but with a different alpha (using withAlphaComponent)
Expected result: the view background colour is the the named one with some alpha.
Actual result: the view background colour is he named colour without alpha.
The issue does not occur if the colour set in the storyboard is any colour but the named one. It does not occur on iOS 14.1 either.
You are presenting the ViewController so it won't work for that you have to add UIView of UIViewController on the other ViewController after that it will work.
[[self view] addSubview:myViewController.view];

How can I set the correct Nav Bar tint color?

I am creating a title view in my navigation bar. I designed my title view with background view color R:255 G:182 B:22 (on photoshop). In my storyboard, I've set the navigation bar tint color with the same RGB code, default style and translucent checked.
I put my image on my navigation title using:
UIImage *titleImage = [UIImage imageNamed:#"Icon-Small-40.png"];
self.navigationItem.titleView = [[UIImageView alloc]initWithImage:titleImage];
When I run the app, you can clearly see a square icon in the title view. The title view has a slightly darker background. I want to make the background the same color. I get the feeling that it has something to do with some storyboard setting but I can't find the issue.
the view has a tintColor property, so
self.navigationItem.titleView.tintColor = ...
Below answer for your navigation bar tint color
self.navigationController.navigationBar.tintColor = [UIColor greenColor];
Trying to make colours match up like this can be maddening. Colour space problems aside, the actual colour of the navigation bar isn’t guaranteed by the API to be the same as its barTintColor. You might find it easier to give the title image a transparent background.

Monotouch UIView Appearance changing UITextField background colors, UIButton background colors, etc

I am trying to implement a custom appearance for UIView when contained in UIViewController.
var viewStyle = UIView.AppearanceWhenContainedIn(typeof(UIViewController));
viewStyle.BackgroundColor = UIColor.Blue;
The result I get from doing this is something ugly, like this:
I tried adding code to change the UITextField/UIButton background by doing:
var txtBoxStyle = UITextField.AppearanceWhenContainedIn(typeof(UIViewController));
txtBoxStyle.BackgroundColor = UIColor.White;
var btnStyle = UIButton.AppearanceWhenContainedIn(typeof(UIViewController));
btnStyle.SetTitleShadowColor(UIColor.White, UIControlState.Normal);
btnStyle.SetTitleColor(UIColor.Black, UIControlState.Normal);
but that doesn't help my result at all (the above image isn't updated from when I changed the button title color from white to black, you'll have to imagine the button's text as black instead of white). Anyone know how to get rid of that ugly blue in the (foreground or background?) of the UITextFields and UIButtons? Bonus if you can figure out why the Title's background is blue as well and how to fix that!

Resources