iOS 7 UIToolBar color - uinavigationcontroller

I have a toolBar in a tableView under iOS 7. It has this default blur and I just want to paint it black.
I am doing this:
self.navigationController.toolbarHidden = NO;
self.navigationController.toolbar.tintColor = [UIColor blackColor];
self.navigationController.toolbar.barTintColor = [UIColor blackColor];
self.navigationController.toolbar.backgroundColor = [UIColor blackColor];
self.navigationController.toolbar.translucent = NO;
With no success... The toolbar still has a "clearColor" and is still translucent.
Am I missing something?
EDIT: I am not using storyboards. The view is not loaded from Nib.
EDIT: I started a new project, and the it works. Still I have to figure out why it is not working in the first project!

if you are using storyboards you can turn off Translucent and change the style to black in the attributes inspector tab (fourth across just before the ruler) in the utilities panel

You need to set it on the UINavigationController. The toolbar is a property of UINavigationController, so you need to set it there. If you are not using Storyboard, you need to create a subclass.
I'm using storyboard. In Storyboard select the UINavigationController (not the embedded view!) and switch to the little shield in the right view (4th element). Then select "shows toolbar" and now you can select the toolbar and set the color.
Hope it helps!

Related

Set overlay for a background page in javafx

I need to set the background overlay to grey as shown in the image below when a popup is displayed. I have set the background page as the owner page to the popup. So other times when the popup is not displaying it has be normal. I was not able to achieve this. Please someone guide me.
A bit late... but you can try and use ColorAdjust in JavaFX:
ColorAdjust dim = new ColorAdjust();
dim.setBrightness(-0.4);
stage.getScene().getRoot().setEffect(dim);
Set it on the stage you desire and it should work.

(Qt) two rows of widgets in a toolbar

I can't figure out how creating a toolbar with two rows of widgets. I'm working on a Python3/Qt4 project.
My guess :
add a widget to the toolbar widget
add a vertical layout (or a QGridLayout, it doesn't matter) to the widget
add the toolbar's buttons to the layout
But all I get is a tiny and empty toolbar : do I need to somehow 'stretch' the widget ?
My Python3 code, trying to insert vertically two buttons in the toolbar :
self.main_toolbar = self.addToolBar('MyToolBar')
self.toolbar_widget = QtGui.QWidget(self.main_toolbar)
self.toolbar_layout = QtGui.QVBoxLayout()
self.toolbar_widget.setLayout(self.toolbar_layout)
button1 = QtGui.QPushButton(self)
button1.setText("button1")
self.toolbar_layout.addWidget( button1 )
button2 = QtGui.QPushButton(self)
button2.setText("button2")
self.toolbar_layout.addWidget( button2 )
The code you posted is fine, it's just that you forgot to add your widget to the toolbar.
You can do this using QToolBar.addWidget:
self.main_toolbar.addWidget(self.toolbar_widget)
It's simple: you really need two toolbars, one under another.
You can't merely add child widgets to a toolbar. Your main_toolbar is presumably of the QToolBar class. You can't simply add a toolbar_widget to it!
Neither you can change the layout of a QToolBar. The toolbar manages the layout of its children itself, you're not supposed to mess with it - it's not designed that way.
The only way of adding widgets to a toolbar is via the addWidget method of the toolbar, not of the layout!
Your code is wrong. What you can do, and all that you can do with a toolbar is:
self.main_toolbar = self.addToolBar('MyToolBar')
button1 = QtGui.QPushButton(self)
button1.setText("button1")
self.main_toolbar.addWidget( button1 )
button2 = QtGui.QPushButton(self)
button2.setText("button2")
self.main_toolbar.addWidget( button2 )
What you want to do is simply not supported by the toolbar. The toolbar may, perhaps, arrange its items in more than one row if they don't all fit. It probably depends on the style. You're free to insert "tall" toolbar widgets that have an internal layout and two sub-buttons inside, but it'll look very ugly.

ViewController max width / mask?

First of all I want to say that I didn't make this myself but I have to edit this code for a friend of mine.
So there is a storyboard with a ViewController called 'PressViewController'.
In this view there are many images side by side. When I go to 'Utilities' > 'Attributes' the 'Width' of this ViewController is set to '10000'.
In the ViewController I can only see a few images. There are like 20 images and I only can see 15. Although I can't scroll in this ViewController there is a way to add more images to it, but I can't find it.
In the 'PressViewController.m' there is a rectangle drawn.
scrollview.contentSize = CGSizeMake(19170, 450);
scrollview.scrollEnabled = YES;
scrollview.backgroundColor = [UIColor clearColor];
The rectangle drawn is '19170' width. This is lager than the ViewController.
So my question is. How can I add more images to my ViewController?
I'll hope someone can help me out. Thanks instead :)

UISearchBar in UINavigationBar changes width when rotating orientation

This is driving me crazy. I am creating a splitview app on iPad.
I have created a searchBar inside the UINavigationBar - something like this...
UISearchBar *searchBar = [[UISearchBar alloc] initWitFrame:CGRectZero];
[searchBar setPlaceHolder:#"Search"];
[searchBar sizeToFit];
[searchBar setDelegate:self];
[self.navigatioItem setTitleView:searchBar];
this works just fine for me displaying the UISearchBar like this...
I also have this UIBarButtonItem set to show Master navigation controller in sidepane.
The problem happens when the device rotates to landscape and the UIBarButtonItem gets hidden. Then the searchBar appears like this...
there is some space on sides which appears to be there since the barButtonItem got hidden and the size of search bar couldn't be updated.
Furthermore, when I rotate the device again, here's what happens to UISearchBar
How can I update the size of searchbar once it has been added to UINavigationBar. Even using autoResizingMask does not work.
searchBar.autoResizingMask =UIViewAutoresizingFlexibleWidth;
What am I doing wrong over here?
I had about the same problem (it wasn't searchbar, but some UIView), and that's how I solved it:
Try creating it with fixed size that won't change. I mean if your navbar minimum size is (for example) 320pt, and barbutton is about 30pt, and you need searchbar to be placed right in the middle (which, BTW is not standart, AFAIK), you'd have to make it 320 - (30+10)*2 = 240pt. Searchbar would be placed right in the middle and will have enough place left free.
This way it will neither change it's size, nor it will affect other items.
Or I would suggest you placing it at right position, not in the middle.
Hope it helped.

Change color of translucent black UINavigationBar

I stumbled upon this many times, never found a solution.
A UINavigationController's navigationBar can be set to black translucent like:
self.navigationController.navigationBar.barStyle=UIBarStyleBlackTranslucent;
Also, there is a translucent property in UINavigationBar, the docs say:
When YES, the navigation bar is drawn with partial opacity, regardless
of the bar style. The amount of opacity is fixed and cannot be
changed. It is permissible to set the value of this property when the
navigation bar is being managed by a navigation controller object.
I tried
self.navigationcontroller.navigationBar.tintColor=[UIColor blueColor];
self.navigationcontroller.navigationBar.translucent=YES;
and a thousand variations: Setting the translucent property first, setting it in the AppDelegate and in the ViewController, setting the barstyle first.
The result is always the same: No transparency. Hence my question:
Is it really possible to change the color of a translucent UINavigationBar to something different than black (preferably within a UINavigationController)?.
I hope there is a review-safe solution.
Thanks, m
Once you know it, it's fairly simple:
self.navigationController.navigationBar.tintColor = [UIColor blueColor];
self.navigationController.navigationBar.alpha = 0.7f;
self.navigationController.navigationBar.translucent = YES;
The translucent property seems only to determine wether the main view should be visible under the navigation bar, and resizes the view appropiately.
To mimic more accurately the translucent effect, meaning that only the background of the navbar is translucent, and the buttons, title and everything else are opaque, you can do like this:
self.navigationController.navigationBar.translucent = YES;
[(UIView*)[self.navigationController.navigationBar.subviews objectAtIndex:0] setAlpha:0.7f];
At least in iOS 6 on an iPhone 4S, you can make a colored translucent navigation bar like this:
self.navigationController.navigationBar.tintColor = [UIColor blueColor];
self.navigationController.navigationBar.translucent = YES;
The alpha setting doesn't seem to be necessary anymore. This also leaves my title bright white and my buttons opaque.
Here is the solution:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:3.f/255.f green:8.f/255.f blue:61.f/255.f alpha:1]];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.navigationBar.barTintColor = [UINavigationBar appearance].barTintColor;

Resources