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.
Related
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.
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;
I am trying to achieve a similar effect to that of the Notes app on iOS in that I have a tableView with a background image and I want the navigation bar to have the same background image but without the text from the tableView overlapping.
Here is the tableView scrolled. As you can see, the text of the tableView overlaps that of the status bar and navigation bar. That is why I want the blur effect on the navigation bar.
In iOS8 there is a new UIView subclass called UIVisualEffectView.
You instantiate it with...
UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; // other styles available
or...
UIVisualEffectView *blurView = [[UIVisualEffectView alloc] initWithEffect:[UIVibrancyEffect notificationCenterVibrancyEffect]; // other styles available
You then can do one of two things.
Either add this in front of the views you want to show through. (Not a sub view but in front of the content).
Or you can take a view and set it as the contentView of the visualEffectView.
This will then automatically add the effect to the content. It even updates when the content is updated so if you have something animating behind it it will show the blurred animation for you.
I want to developer app with a custom navigation bar like in the following images:
I think that i need to subclass UINavigationBar and add button to centre of nav bar, but i don't really know how to make navigation bar look like on image. Can you please give me advice what should i do, links to any kind of documentation would be awesome!
Similar questions about navBar that doesn't helped me:
ios back button in the bar
Use custom Navigation Bar in iOS
Custom Navigation Bar in iOS 5
rogcar
EDIT:
My idea is next: make custom navigation bar height little bigger than default size, and add background image with arrow in it and with some transparency on the edges.
If you want a button (you probably do want) you can achieve it completely by subclassing UINavigationBar. You should remember that height of UINavigationBar is read-only property.
Style but not tappable:
So let's assume we subclass the navigation bar and add button there. You could do this and it will be going look great. For example:
- (void)drawRect:(CGRect)rect
{
self.backgroundColor = [UIColor lightGrayColor];
UIButton *myButton = [[UIButton alloc] initWithFrame:CGRectMake(self.frame.size.width/2-50, 0 , 100, 100)];
[myButton setBackgroundColor:[UIColor lightGrayColor]];
[myButton setTitle:#"Normal" forState:UIControlStateNormal];
[myButton setTitle:#"Highlighted" forState:UIControlStateHighlighted];
[self addSubview:myButton];
[self sendSubviewToBack:myButton];
}
But you will facing a problem that your button is non tapeable below UINvaigationBar. (I post an image on the bottom of the answer)
So there is clearly not a path you want to follow. Don't even try that.
Style but not tappable 2:
You may override this method in your navigation bar subclass
- (CGSize) sizeThatFits:(CGSize)size {
return CGSizeMake(custom_width, custom_height);
}
And then mask it using UIBezierPath for example
The right (tappable) way:
You have to create a view stick to your UINavigationBar. What i will do here (if you want it to every screen) is:
Make a Category of UIViewController which can draw (for example - this is easiest way) UIButton.
Style this 'UIButton' whatever you want (if you want
Pin action to 'UIButton': [btn addTarget:self action:#selector(menuShow:) forControlEvents:UIControlEventTouchUpInside];
menuShow: method should be declare in your category
You can call drawing button every time you want to redraw view controller.
As you can see there there will be two separates View: UINavigationBar and UIButton. This is allow you to set content under this little button and make it tapable.
So why just don't hide navigation bar, and use different view? Because iOS7 ;) When Apple change it in iOS7 for example then you have to rebuild your pseudo NavigationBar, with only additional view, you don't need to do anything.
You do not need to subclass UINavigationBar. Create UIView add to it UIImageView as background with image in the shape you need, add button.
Subclass UINavigationController hide UINavigationBar, add custom navigation bar.
First Hide navigation bar using -
self.navigationController.navigationBarHidden = YES;
Then create UIView with required height,height of navigationBar is 44px.Then create background image view, object of required UIButton and add all objects on created UIView as a subview.It will look like navigationBar.Thank you.
You can add your custom shaped view as titleView on the navigation bar.
Just make sure that clipsToBounds is set to NO, so it doesn't get clipped.
I've found out that the height of a UITabBar is 49px (or 50px, depending on the source).
Because I don't like to use too much hard-coded values in my code I was wondering if it is possible to retrieve the height of the tabbar programmatically.
Kind regards,
Niels R.
PS: The reason I'm asking is because I have a view controller (with a list view containing text fields) that is either simply pushed by the navigationcontroller (pushViewController) or presented as a modal (presentModalViewController). As soon as the keyboard show up, the size of the view is reduced, but I have to take into account that the tabbar is only visible when the view controller is pushed and not presented as a modal.
I don't totally understand your P.S., but you can do:
tabBarController?.tabBar.frame.size.height
If you want to get the standard height for the UITabBar control then you can do:
UITabBarController *tabBarController = [UITabBarController new];
CGFloat tabBarHeight = tabBarController.tabBar.frame.size.height;
prettier
CGRectGetHeight(self.tabBarController.tabBar.frame)
check this in your vc
bottomLayoutGuide.length
In Swift 3, you can retrieve the height of the UITabBar with this code below.
self.tabBarController!.tabBar.frame.size.height
Which will return a CGFloat value of the height
If an object is based on UIView (which most visual elements in the library are), you can get the size from the ivar "frame".
UITabBar is inherited from UIView as long as you mhave access to your UITabBar instance you can access and modify the frame of UITabBar,
CGRect myRect = myTabBar.frame;
Try to use the intrinsicContentSize property of the tab bar like this
let tabBarHeight = self.tabBarController.tabBar.intrinsicContentSize.height