Custom navigation button but the text is not clear as the system - uibutton

I use custom view to set a UIButton on the navigation bar.
But the text on the button like below:
is not like the default button text that clear.
I tried to add another label on the button, but it seems failed.
I also tied code like this, but seems also not working.
doneButton.titleLabel.layer.shadowColor = [UIColor blackColor].CGColor;
doneButton.titleLabel.layer.shadowOffset = CGSizeMake(0, -1.0);

These code just works well.
button.titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont smallSystemFontSize]];
button.titleLabel.textColor = [UIColor whiteColor];
button.titleLabel.shadowOffset = CGSizeMake(0,-1);
button.titleLabel.shadowColor = [UIColor darkGrayColor];
I got it from https://github.com/boctor/idev-recipes which is very great for custom UI fulfillment.

Related

MFMessageComposeViewController: Cannot Style "Cancel" Button in Dark Mode

I'm currently trying to style the "cancel" button that is in the top right corner (the navigation bar and the button are both grey) and I am having no luck. I've tried calling several different methods and none have worked. My project builds for iOS12.1 and I'm testing via iOS15.4. Here is what I've tried so far:
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:#"Futura-Medium" size:17.0f],
NSFontAttributeName,
[UIColor blueColor],
NSForegroundColorAttributeName,
nil]];
MFMessageComposeViewController *messageController;
[messageController.navigationBar setTintColor:[UIColor blueColor]];
messageController = [MFMessageComposeViewController new];
[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:[NSArray arrayWithObject:[UINavigationBar class]]].tintColor = [UIColor RepublicBrightBlue];
The gray color for the button is likely coming from the global tint color for your application. This is by default AccentColor that comes within Assets (this is mapped via Build Settings). Note that you can define separate global accent colors for Any, Light, Dark
If you're just interested in styling this MFMessageComposeViewController the following worked for me to change the tint color for all views within the message view:
MFMessageComposeViewController *messageController = [MFMessageComposeViewController new];
[self presentViewController:messageController animated:true completion:nil];
[UIView appearanceWhenContainedInInstancesOfClasses:[NSArray arrayWithObject:[MFMessageComposeViewController class]]].tintColor = [UIColor redColor];
Which results in

changing tintColor makes backbutton disappear

I am trying to modify navigationBar's appearence by setting it's tinkColor & barTintColor
start up with doc on page https://developer.apple.com/documentation/uikit/UINavigationBar?language=objc
I tried to modify the navbar on the [viewDidLoad] hook of my ViewController as follows
self.navigationController.navigationBar.translucent = NO;
UIColor *barColor = [UIColor ColorA];
self.navigationController.navigationBar.barTintColor = barColor;
UIColor *backButtonColor = [UIColor ColorB];
self.navigationController.navigationBar.tintColor = backButtonColor;
But then the back button then disappeared and the change of barTintColor dosen't seem to be effective
What am I doing wrong?
Weird behavior.
check please title of previous viewcontroller
check please if there is something like(hiding back button somewhere):
self.navigationItem.leftBarButtonItems = []
self.navigationItem.hidesBackButton = true
double check color for backButtonColor(be sure that barColor != backButtonColor). Try some native color: [UIColor red]

UITextField – opacity of left placeholder

I have a UITextField with opacity 0.2 (the background is red), and I tried to add a white icon as textField.leftView like so:
self.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"lock.png"]];
self.leftView.layer.opacity = 1.0;
self.layer.opacity = 0.2;
self.leftViewMode = UITextFieldViewModeAlways;
The problem is that the leftView seems to get the same opacity as the whole text field, and as they both are white, the result is that I see nothing. Do you see any other way/what I do wrong? Any help is appreciated.
Okay, found the solution. Seems I didn't think it fully through.
The problem was the opacity being "inherited" by all colors of the view, while I only wanted the background to be opaque. So, I just made the background opaque :) Like so:
self.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.2];

Need Help Setting UITableViewCell's Background Image

I'm using a background image for my UITableViewCell.
If I just set the background of the cell, but keep everything else the same, I get this:
I'm if I use this code in viewDidLoad and it fixes the cell but it is making the navbar transparent:
self.navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"background.png"]];
self.tableView.backgroundColor = [UIColor clearColor];
Is there way to get the navbar back and get the cell looking normal?
For the most part, I don't believe UIPopovers have many visual options as far as background.

Objective C: How to change text color in navigation bar

I have changed my navigation bar color via the following code
navconFvc.navigationBar.tintColor = [UIColor colorWithHexString:#"faf6f5"];
The code worked but the text color also needs to be changed (see screenshot below). Also the refresh button logo on the right is affected as well
The same issue occurs if I navigate to another page in the stack
Question: How can I change the color of the
title text
Back button text and
right bar button icon color?
After I changed the background color of the navbar?
In iOS 7, just use:
self.navigationController.navigationBar.titleTextAttributes = #{NSForegroundColorAttributeName : [UIColor whiteColor]};
Change [UIColor whiteColor] with whatever text color you want
For the title here's the way:
iPhone Navigation Bar Title text color
And for the custom buttons here's the way:
adding buttons to ui navigation controller bottom bar
To change text color:
_navController.navigationBar.titleTextAttributes
= #{UITextAttributeTextColor : [UIColor blackColor]};
Adding refresh button and color it:
UIBarButtonItem *button = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self action:#selector(reload)];
[button setTintColor:[UIColor blackColor]];
self.navigationItem.rightBarButtonItem = button;
Variables that effect navigation bar background:
_navController.navigationBar.backgroundColor = [UIColor whiteColor];
_navController.navigationBar.tintColor = [UIColor whiteColor];
_navController.navigationBar.translucent = NO;
I just put together a simple UIViewController subclass that adds a customizable back button that allows you to change text colors. It basically adds some willAppear/willDisappear logic to animate the back button the way the UINavigationController does while using the leftBarButtonItem property. You might extend this to also do the rightBarButtomItem as well.
https://github.com/typeoneerror/BBCustomBackButtonViewController