When presenting a WKInterfaceController, how can I change the color of the title used to dismiss the controller? - objective-c

In my watch app, after presenting a controller with presentControllerWithNames:contexts:, is it possible to change the color of the title in the status bar? For example, in Apple's WatchKit Catalogue sample they have a controller they present modally with "Dismiss" set as the title. In storyboard, the title for this controller appears to have the global tint applied to it, but when running the app in the simulator, the color defaults to white.
If possible, how can I make a presented WatchKit controller respect the global tint color?
edit: Attaching a screenshot for clarity.

Yes, Global Tint is the answer.
go to storyboard file
select the interface controller desired to be colored
click 'Utilities'
click 'File Inspector'
Find 'Global Tint', then use 'RGB sliders' under 2nd Tab of the Color pane

With the current WatchKit SDK, the global tint color does not apply on the WKInterfaceControllers title that are presented modally. I am not sure if this is a bug in the beta version or a feature... I hope Apple will fix this.

It is possible to change the global tint color. You can change the global color in the "Show the File Inspector" Storyboard.
Sorry I don't have the 10 reputation points required to post a screenshot. ^^

Related

Disable background and change tint color for custom popup

In my project I created some custom popups. Just like for example the UIActionSheet I would like to create an overlay, disable other interactions and gray out the tintColor of the UITabBar buttons, UINavigationBar buttons and so on.
As for now I've managed to fix this by manually creating a background overlay, disable the interaction by adding this overlay over other views and change the tintcolor manually.
I've searched for an API method to automatically solve this problem, but without success.
Hoping to find some good suggestions here at SO.
Edit
The answer I was looking for is called tintAdjustmentMode:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/occ/instp/UIView/tintAdjustmentMode
Add a new view in your xib
set background color as a black color and set the opacity to 50%
Create your popup on this view.
Put this view in the main view.
Finally just hide & unhide this view according to your requirement.
In this you don't need to disable any other control.

iOS 7 multitasking switcher: Navbar appears black

The preview window/multitasking switcher shows a weird behaviour in iOS 7.
Here is how it appears when I set this property for both apps.
self.navigationController.navigationBar.translucent = NO;
Now for the white app I commented the line.
Now when I run it again and go directly to the switcher, this is what I get:
If I run the app and then go to the home screen or any other app and then go to the switcher, this is what I get:
Is there any way to correct this problem while having translucent navbar?
Thanks.
I ran into this as well. Since you don't have any content under the translucent navigation bar (and/or tab bar or tool bar), it can sometimes appear black in the app switcher. I was using a collection view that was constrained to the top and bottom layout guides and so there was nothing behind the tab bar and navigation bar. When the app is in the foreground it looks correct because there must be some default background color applied by Apple (maybe on the UIWindow) so you don't see through to the springboard. This background color seems to be gone (or black) when in the app switcher causing it to look like that.
The problem goes away on view controllers that are set to extend under top and/or bottom bars:
self.edgesForExtendedLayout = UIRectEdgeTop | UIRectEdgeBottom;
or in Interface Builder:
If that doesn't fit you needs or you still have other view controllers that don't extend under top and bottom bars you will still get the black bars in the app switcher. The way I solved it was to set the UIWindow background color in my appDelegate.
self.window.backgroundColor = [UIColor whiteColor];
Instead of doing it in code, you can also do it via Storyboard.
In the navigation bar of your root navigation bar, make sure you turn off its translucency.
I reckon it's a simpler solution.

How do I fix empty 44px space in iOS7 view with ViewDeckController?

I am in the process of transitioning an app to iOS7. All of the views throughout the app have a 44px empty space at the bottom that appears to be for a bottom toolbar or something, but I am not trying to display a bottom toolbar. This space also exists on views that do have a bottom toolbar and the toolbar just shows directly above it.
The red space shown is actually a view behind the black view. No matter what size I set the frame of the black view to, the red space is always shown. I am also hiding the status bar in plist, so don't know if this is an artifact from that or if it has something to do with navigation bar as they are both normally 44px in height.
I have looked at the transitioning guide and haven't found anything that's worked. Any ideas to what could be causing this and how to fix?
UPDATE:
I have tried setting edgesForExtendedLayout = UIRectEdgeAll and extendedLayoutIncludesOpaqueBars = YES (also tried NO) with no effect. When I look at the subviews of the navigation controller it shows a UIToolBar as hidden, but shows it contains a frame in the exact area the view refuses to resize to even with autolayout constraints.
UPDATE 2:
This is actually a problem with ViewDeckController (https://github.com/Inferis/ViewDeck) and the way it sets it's center view bounds.
I believe it has to do with the UINavigationBar. Try toggling the following options in Storyboard and see if it solves the problem. Namely, the 'Extend Edges' options:
These options can also be set in code with the edgesForExtendedLayout and extendedLayoutIncludesOpaqueBars properties on UIViewController.
If you are transitioning to iOS 7, you should be using an Auto Layout constraint to anchor to the Bottom Layout guide. Control drag from your view to the Bottom Layout guide and choose Vertical Space from the popup menu.
Using frames in iOS 7 is harder and is the way of the past.
Auto Layout is hard to grasp at first, but it is very powerful once you get the feel.
This is actually a problem with third party library ViewDeckController (https://github.com/Inferis/ViewDeck) and the way it sets centerViewBounds for IIViewDeckControllerIntegrated. I was able to figure it out after changing to IIViewDeckControllerContained and seeing the view sized correctly.
In IIViewDeckController.m, just return self.referenceBounds for iOS7 like it does for IIViewDeckControllerContained.

Use custom Navigation Bar in iOS

I added a Navigation Bar to the .xib.
I did that because I want to customize a lot of things of it. I want my navigation controller to use that navigation bar in that screen.
I created the outlet named navBar and did:
[self.navigationController.navigationBar = navBar;
But it says that navigationBar is readonly. Is it possible to link my existing navigation controller with the navigation bar that I added to the screen?
It sounds to me that you may not actually want to use a UINavigationBar. As it states in the reference documentation:
The UINavigationBar class implements a control for navigating hierarchical content. It’s a bar, typically displayed at the top of the screen, containing buttons for navigating up and down a hierarchy. The primary properties are a left (back) button, a center title, and an optional right button. You can specify custom views for each of these.
So if you're planned customizations go beyond adding buttons, changing it's color / background, opacity, hiding etc.. you might be better off creating a UIView that mimics the look & feel of a navigation bar.
Here's an example of how to give your UIView that gradient look of a navigation bar.
It's far more flexible and actually quite easy to do BUT you've got alot of reading and testing ahead of you :).
Just in case if it's just buttons you're thinking of adding you might be better off using UIToolbar instead
You can't do that. Since the navigation controller's navigation bar has a lot of settings embedded, it's a readonly property and you shouldn't be able to change it.
What exactly are you trying to achieve that you need to do that via interface builder. I mean, with the newest APIs, it should be simple to do everything you want with a few lines of code, by customising the original navcontroller's navbar.
You would not manage a navigation bar in interface builder. Also, you would not try to set the navigationBar property of the navigation controller.
To make changes you would make changes to the navigationItem property of the navigationBar
[self.navigationController.navigationBar setItems:newNavItems];
You can also make other changes to the navigationBar such as setting a background image or making it translucent
self.navigationController.navigationBar.translucent = true;
[self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:barMetrics];

How to change background color of storyboard in Xcode?

I'm working with white text (labels) in Xcode, and currently I can't see them because the background of the storyboard is also white. How do I change the appearance of the storyboard?
To clarify, I do not want my text to change color, I only want to change the appearance of the storyboard so that I can develop more easily.
If you are referring to the white in your view controller:
Select the View
Go to inspector (right panel, 4th item)
Change the background color field (section view)
I'm not sure you can do what you're trying to achieve. My best advice to you would be to create a dark coloured UIView which you can place behind the UILabel. Once you're happy you've got the UILabel setup the way you want it you can then just delete the UIView.