Little line above status bar issue - ios

In my application there was a small line (about 1px white line) above status bar. What could be the problem?

If you have the same background color throughout the app, this should help you (put it in application:didFinishLaunchingWithOptions:) :
self.window.backgroundColor = [UIColor yourColor];
Swift:
window.backgroundColor = UIColor.yourColor();

Related

How to change React Native cursor color?

I am using React Native and I would like to change the cursor color of a text input. I actually got the default blue color.
How can I set a global color either in JavaScript or in AppDelegate ?
There is actually a prop doing this for TextInput : selectionColor
<TextInput
selectionColor={'green'}
/>
Here is the documentation.
Best way to accomplish this, if you want consistence trough the app is putting the bellow code in your root file (index.js)
import { TextInput } from 'react-native'
TextInput.defaultProps.selectionColor = 'white'
/*class....*/
Many here suggested using selectionColor:
import {TextInput} from 'react-native';
TextInput.defaultProps.selectionColor = 'red';
As of RN 0.63, this solution is still inefficient for at least two reasons:
On Android, highlighted text gets the same bright color as the cursor, and the drop-shaped guides below highlighted text are still stuck with the default color;
Any input field or textarea embedded in WebView components will get the default cursor color on both platforms.
Therefore, the right way to change the cursor color is by editing the native settings instead.
Android
Go to android/app/src/main/res/values/styles.xml and add the following lines to the custom section:
<item name="android:colorControlActivated">#FF0000</item>
<item name="android:textColorHighlight">#FF9999</item>
iOS
Go to ios/MyApp/AppDelegate.m and before [self.window makeKeyAndVisible]; add:
self.window.tintColor = [UIColor colorWithRed:1.0f green:0.0f blue:0.0f alpha:1];
Finally, rebuild the apps to see the result of your edits.
You can just change the cursor color by changing the selection color according to the documentation as shown bellow,
<Input
...
selectionColor={"black"}
/>
Yes, we can do it by setting tint color.
In AppDelegate.m of project.
Adding the below code between self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; and [self.window makeKeyAndVisible];, you can change the global tint color.
self.window.tintColor = [UIColor redColor]; // Here is your color.
Or, adding the below code after [self.window makeKeyAndVisible];, you can change the tint color of TextInput/UITextField.
[[UITextField appearance] setTintColor:[UIColor redColor]];
Nothing happens when you change the UITextView's tint color.
And I couldn't find a way to implement it with a style of JaveScript.
For React Native 0.62 +
import {TextInput } from 'react-native'
TextInput.defaultProps = TextInput.defaultProps || {};
TextInput.defaultProps.selectionColor = 'transparent';
Add these line before Main function call in App.js
Eg :-
..Other code
TextInput.defaultProps = TextInput.defaultProps || {};
TextInput.defaultProps.selectionColor = 'transparent';
const App = () => {
...Other code
You can use:-
cursorColor="color_name"
in the TextInput

Custom barTintColor for navigationBar

I am trying to get a customized color for my apps navigation bar and it's not coming up right. The hex code for the exact color I need to use is the blue #023883. I looked up the rbg percentages from this site: http://www.colorhexa.com/023883 and the percentages are: rgb(0.8%,22%,51.4%). I put it inside my code like this:
self.navigationController.navigationBar.barTintColor = [UIColor
colorWithRed:0.8 green:22 blue:51.4 alpha:1.0];
self.navigationController.navigationBar.titleTextAttributes =
#{NSForegroundColorAttributeName : [UIColor lightGrayColor]};
self.navigationController.navigationBar.backgroundColor = [UIColor
whiteColor];
self.navigationController.navigationBar.translucent = YES;
I also tried to implement code that enables the use of inputting hexcode for the color value but that didn't work either. Is there another way for me to be able to achieve this color? (I also tried to put only blue at 100 and it still wasnt dark enough a color)
You forget % ,it should be
self.navigationController.navigationBar.barTintColor = [UIColor
colorWithRed:0.008 green:0.22 blue:0.514 alpha:1.0];
Edit,about how to make statusBar white
set this key to NO in info.plist file View controller-based status bar appearance.Click the plus icon in the right of Information Property List,then you click a V in the new row,it will auto complete,the first one is this key
In app delegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[application setStatusBarStyle:UIStatusBarStyleLightContent];
return YES;
}
Step-1
Select your NavigationController
Step - 2
selet the Navigation bar
Step-3
you can get the Navigation bar attributes
Step -4 in Here you can change Title , Font, Background color , etc.
statusBar - Transparent
Target --> Genral --> U get the following result change Status Bar Style --> Light , please follow the image.
don't forget to set NO in plist String Name is --> View controller-based status bar appearance
You are using colorWithRed:green:blue:alpha wrong.
You are supposed to enter percentages (0.8, 22 and 51.4 in your case), but are entering them in a wrong manner.
Please enter 0.008, 0.22 and 0.514 instead:
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.008 green:0.22 blue:0.514 alpha:1.0];

How to set UIBarButtonItem tintcolor to non default UIColor

I've looked through all the typical navigation bar tintcolor tutorials and questions. I have a set tint for the navigation bar, but I have a mail icon that needs to change to a custom color when there is mail. (like reddit orange mail icon)
I can set the tint properly only when using system UIColors.
self.leftNavigationBarButton = [[UIBarButtonItem alloc] initWithImage:someImage style:UIBarButtonItemStylePlain target:self action:#selector(foo:)];
self.navigationItem.leftBarButtonItem = self.leftNavigationBarButton;
self.leftNavigationBarButton.tintcolor = [UIColor redColor];
However if I then use a custom color.
self.leftNavigationBarButton.tintcolor = [UIColor colorWithRed:100 green:40 blue:20 alpha:1.0];
It makes the icon white. Does anyone know what's going on or how I can use a custom color?
I figured it out from this answer https://stackoverflow.com/a/5642229/1732711.
Short answer is to divide the RGB values by 255.0.
self.leftNavigationBarButton.tintcolor = [UIColor colorWithRed:100/255.0 green:40/255.0 blue:20/255.0 alpha:1.0];

remove alpha from UIAlertView in iOS 8

I would like to make the alert views in my app a solid white, instead of an semi-transparent white. Since UIAlertView extends UIView, I have tried the following:
alert.backgroundColor = [UIColor whiteColor];
alert.alpha = 1;
alert.opaque = YES;
but the alert continues to transparent. How can I make it have a solid white background?
It is advised against doing this, since simply solutions (like alpha = 1.0, etc) will not work. Therefore you are likely to be creating issues for the future if you try working your way around this. My advice is not to do it, but if you have to then subclass UIView and do it that way.
If you want alerts with solid white background without transparency then you can do this:
UIVisualEffectView.appearance(whenContainedInInstancesOf: [UIAlertController.classForCoder() as! UIAppearanceContainer.Type]).backgroundColor = UIColor.white
it works for both UIAlertController and UIAlertView.

Opaque white status bar in iOS7

First off, I'm aware that the two well know ways of modifying the status bar are
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
and
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
However, with the default style, the status bar has black text with a clear (or translucent white - I can't tell) background. A view in my application slides up at certain points, and it is viewable through the status bar. Is there a way to make the status bar background an opaque white color?
Thanks
I solved this by creating a Base View Controller that each VC inherits from, and adding the following to viewDidLoad:
//Make status bar opaque
CGRect blocker = CGRectMake(0, 0, self.view.frame.size.width, 20);
ColoredLineSegment *blockerView = [[ColoredLineSegment alloc] initWithFrame:blocker]; //ColoredLineSegment is just a colored in rect
blockerView.color = [UIColor whiteColor];
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubview:blockerView];
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] bringSubviewToFront:blockerView];
Try this in AppDelegate.m :
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:255.0/255 green:255.0/255 blue:255.0/255 alpha:1.0]];
It should work !

Resources