I am trying to make an uiview look just like the default uinavigationbar in ios 8.
I don't want to hardcode the values so would like to take the uinavigationbar color, height , width and the border at the bottom and apply the same to a custom uiview.
Is there any way I can achieve it ?
self.headerBar.backgroundColor = self.navigationController.navigationBar.backgroundColor;
I tried the above but it didn't work.
K I finally had to combine the following
[UIColor colorWithRed:(247/255.0) green:(247/255.0) blue:(247/255.0) alpha:1];
for the uiview colour than had to put in another uiview that i added as a subview to the original view with small height so that it looks like a border and gave it colour dark gray and alpha 0.4f. One thing to note here is that the border can also be created using layer but that by default doens't take care of orientation changes.
As for height width just gave the height width as per the superviews bounds to which this custom navigation bar is to be attached.
Well you can use UIToolBar and set its properties accordingly as in UINavigationBar, like tintColor, barTintColor, translucent, etc..
Note: UIToolBar inherits from UIView
If you are using UIView and want to get the navigation bar color then its the barTintColor property you should use and not the backgroundColor
self.headerBar.backgroundColor = self.navigationController.navigationBar.barTintColor;
Related
I have used a UIVIEW . I want to make transparent the UIVIEW. But when I want to chage alpha 0.0 from storyboard for make UIVIEW transparent, textfield, label and other component also transparent. I want to make transparent UIVIEW, not other component of the view. Here is the image
Please help me to make visible other components in UIVIEW transparent
Set your UIView's backgroundColor to UIColor.clear.
Instead of changing the alpha of the UIView, you can make the background color of your UIView as white with alpha component 0.5 or something
myView.backgroundColor = UIColor.black.withAlphaComponent(0.5)
If you want it to be completely transparent, you can set backgroundColor to clear from storyboard as well as code.
myView.backgroundColor = .clear
You just need to change the transparency not of the UIView itself, but of its
background color.
For example:
I set the color of the UIView transparent, while the UILabel remained its settings.
In order to create a semi transparent color, you can use the following code:
yourView.backgroundColor = UIColor.white.withAlphaComponent(0.5)
Hope this will help you!
Go to Main.Storyboard and select the view you want to make transparent.
From the Attribute Inspector select background color as custom.
Then set your desired color and decrease the percentage of Opacity of the color.
I am using a custom titleView in my UINavigationItem that contains a UILabel. After changing the text in the UILabel, I then resize the titleView accordingly. However, the UINavigationBar does not reposition the titleView properly. How can I get the navigation bar to update?
After resizing the titleView, do the following:
navigationItem.titleView = myTitleView
navigationController?.navigationBar.setNeedsLayout()
Both lines are needed.
Do not bother to implement sizeThatFits in your view, as it will have no effect on the repositioning behavior.
Tested in iOS 10.
How can I create a popup window like in this picture:
I can create UIView and show it with a toolbar and tableview but I don't know how can I show a black overlay and is there a simple way to do this?
That is just an UIViewController with the modalPresentationStyle property set UIModalPresentationPageSheet or UIModalPresentationFormSheet
I give you simple trick:
Create one custom UIView (dimView) which frame is similar to window.bounds and BackGroundColor is black and alpha = 0.5f;
Add another custom UIView with on UITableView which style is grouped and also you need to add UINavigationBar with done UIBarButtonItem
And add your custom controls on UITableView's cell.
I have a UIView which includes a UIButton which is partially on UIView. I have a problem when I draw a border on my UIView. Please have a look at my screenshot:
You can see the border is above the UIButton, why? Can anybody suggest? Thanks
Thanks for aăâ, I found a solution.
Basically the border is always drawn on top of everything
What I did is:
Create a UIView with color of border
Create another UIView as the child the main UIView which is a little bit smaller than the first one. The color of this newly create UIView is the main color
Here is the code:
self.layer.cornerRadius = 15;
self.layer.masksToBounds = YES;
self.backView.layer.cornerRadius = 15;
self.backView.layer.masksToBounds = YES;
The result is:
It's more or less what I need although it's not perfect.
It could have to do with the order that the objects are drawn. In your storyboard's "Document Outline", views that are lower down in a view controller's outline are drawn later. Perhaps the button is not the last drawn view, like you want?
I'm developing an iOS 4 application.
I have a main view that contains another UIView, named shadowView, with an UIWebView inside. This shadowView has black as background color and alpha = 0.3f.
My problem is that UIWebView inherits shadowView alpha value, and I don't want that, I need UIWebView has alpha = 1.0.
Do you know how can I do that?
If I understand your question, you have added a UIWebView to a UIView which has an alpha of 0.3.
On iOS, any sub-views inherit their parent views alpha values (or rather, the parent view 'masks' the sub-view).
It sounds as if you want your shadowView to have a translucent background: rather than setting the alpha of the view, you should instead do this:
[shadowView setAlpha:1.0];
[shadowView setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.3]];`
...which will (as long as your view isn't set to be opaque) give you a nice translucent background and allow your sub-views to not appear transparent as well.