How can I edit top status bar at AppleWatch? - ios

I'm beginning with WatchKit and I would like to know hoy to edit the aspect of topbar in a AppleWatch app. I would like to change the color and also to hide it in some of my views because I want to focus my user to perform one action.
Thanks!

It is impossible to edit the status bar appearance. There are some strong restrictions:
Status bar cannot be hidden
There are not ability to modify the black background
You cannot add or modify the back button or another image
The only thing you can do is to change the title color using tint color in your storyboard and the text both of through storyboard and source code.
Change color
Change text
[self setTitle:#"MyTitle"];

Related

Change color of Add to Siri button on INUIAddVoiceShortcutViewController in iOS?

I am trying to change the color of the Add to Siri button and the Cancel button on the view controller of type INUIAddVoiceShortcutViewController provided by Apple, but I couldn't find it in the documentation.
Is there any way to do this? Thanks in advance for your help.
The INUIAddVoiceShortcutViewController adopts this color from your app's tint color.
You can try changing the presenting view controller's tint color prior to presenting (and then changing it back upon dismissal).
Or you might want to try setting your global tint color using UIAppearance in the same way (before the presentation and after dismissal). For example, you can set your app window's tintColor like this:
window?.tintColor = UIColor.blueColor()

Back button showing as different colour on screen?

To experiment with the back button in a navigation controller set up, I added a button programmatically without using storyboard and without using the default navigation bar and back button you get for free with the navigation controller.
In App Delegate I simply said:
navigationController.isNavigationBarHidden = true
I set the button to a simple black and white image icon - but when I run it in the simulator the image shows as blue.
Does anyone know why this might be? It seems to still be picking up the navigation controller colour of blue but I have set the NavigationBarHidden to be true.
from assets, make sure the photo is selected and go to attributes inspector and change “render image as” to Original, same applies for tab bar items images

UIViewController - set color of Navigation bar text on Activities popup

Am creating a UIActivityViewController that is needed in both iPhone and iPad, supporting both iOS 8 and 9.
The app navigation bars are dark colored with the text appearing white-ish.
The UIActivityViewController has been subclassed and I am adding a tintColor here:
myActivityViewController.modalPresentationStyle = UIModalPresentationPopover;
[self.viewcontrollertoPopFrom.navigationController presentViewController:myActivityViewController animated:YES completion:^{
[[UINavigationBar appearance] setBarTintColor:[UIColor myDarkerColor]];
}];
and also currently in the viewDidLoad of the UIActivityViewController subclass
This results in the bar appearing the way I want in the chosen activity such as email. So far so good.
The only issue I have is with the "Activities" popup that appears when the user selects the "more" button on the list of actions the user can select.
I have tried manipulating the UINavigationBar for both the system and the view in every combination I can think of to no avail. I end up with this:
What am I missing?
Looking as to why I was seeing white text to begin with, a colleague pointed out that the app was likely setting the appdelegate.window to white.
So now right before I alloc the UIActivityViewController, I set the window to the tint I want:
[[UIApplication sharedApplication].delegate.window setTintColor:[UIColor myColor]];
Then in the UIActivityViewController completionWithItemsHandler I set it back to it's original color.
While this doesn't set the UINavigationBar to the theme color, it does set the "Done" button to that allowing the user to see it.
Try [[UINavigationBar appearance] setTranslucent:NO]
This property is set to YES by default, and according to Apple's documentation:
If you set this property to NO on a navigation bar with a translucent
custom background image, the navigation bar provides an opaque
background for the image using black if the navigation bar has
UIBarStyleBlack style, white if the navigation bar has
UIBarStyleDefault, or the navigation bar’s barTintColor if a custom
value is defined.
So setting the translucent property to NO and setting the barTintColor to your custom value should do the trick.
UPDATE:
It looks like because the user sorting screen ("Activities") is generated by UIActivityViewController, you will not be able to customize its navigation bar beyond the tint color, which appears to only affect UIBarButtonItems:
UIActivityViewController is still an API only provides custom
functions, but not custom UI. You can’t change the way it looks. The
only part of visual style you can change is the icon of your custom
UIActivity subclass. (Source)
I am sorry to say that you will either have to stick to the system colors in UIActivityViewController, or create a custom control that is customizable. A quick Cocoapods search reveals that there are not any recent third-party controls that will let you do this, but I would highly encourage you to share it if you decide to!
UPDATE 2
Despite that the bar's tint color cannot be customized, this answer provides a workaround for altering the color of the bar's navigationItems by setting the tint color of the application window.

How can I set the nav title's tint color for a modal interface in WatchKit?

In WatchKit, I know that I can set the "Global Tint" value in my storyboard file to adjust the navigation title's text color in my interface controllers.
However, whenever I present a modal interface controller in my application, I'm noticing that the InterfaceController's title shows up as white, not the global tint color.
Here's my tint color setting on the storyboard file:
Here's an example of the issue I'm finding:
How can I get the title of a modal to use the global tint color?
With the current SDK, you are not able to change the title color of Modal screens. The title will always be white.
The global tint color does not apply to Interface Controllers presented modally.
You're manually changing the title on the Model Interface Controller from 'Close' to 'Modal View'. Usually it would display 'Close' and I believe the Tint Colour might only apply to wherever your App's Executable Name is displayed.
I might be wrong, and I understand your confusion. Try filing a bug report for this issue or raising it in the WatchKit Developer Forums?

Change text color of default back button in storyboard

How to change text color of default back button in storyboard.(Both through storyboard and programmatically)? The default color which appears is blue. This question helps in setting text for back button but not the color.
The color of the back button will be set from storyboard global tint color.
Nitish,
In your storyboard sidebar make sure you select the Navigation Bar tab of your Navigation Controller - not your table view. Then change the background color of your navigation bar to whatever you have set. Some blue color. As far as I know you can't change the color of your back button within storyboard so after you set the Navigation bar controller color in storyboard like the picture:
Then you can accomplish this by putting the following code in your viewDidLoad method:
self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; //your color of what you want, I assume you want white based on your background color
And the outcome will be like so:
through StoryBoard you can easily set the tint colour.
Select the Navigation Bar tab of your Navigation Controller and then in attributes inspector you can select the tint colour.
Using Storyboards - no code changes - I had somehow reset my BACK button to yellow (and boy has that been irritating!) I clicked on the 'Tab Bar Controller' within the 'Tab Bar Controller Scene' and then changed the 'Global Tint' in the 'File Inspector' Hooray! You can actually read the BACK button now.
This is my fix :
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor whiteColor]}];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
It works for iOS 7+.
To change the color of the back button for the whole app in Storyboard, select the Navigation Bar in the Navigation Controller. Select the Show the File Inspector in the Utilities Pane. At the bottom of the Interface Builder Document section, set the Global Tint. This will set the color of the back button as well as the Title text of the Navigation Bar for all the View Controller in your app to the color you select.
In Xcode 11 you can simply set the tint property for the Navigation Bar object inside the attributes inspector.
See screenshot below:
It took some time for the changes to take place on the preview for me, but you can see the changes when you run your app.

Resources