uinavigationbar

UINavigationBar slides away instead of staying on place

岁酱吖の 提交于 2019-12-05 15:56:30
I created demo project to show the problem. We have two view controllers inside UINavigationController. MainViewController which is the root. class MainViewController: UIViewController { lazy var button: UIButton = { let button = UIButton() button.setTitle("Detail", for: .normal) return button }() override func viewDidLoad() { super.viewDidLoad() navigationItem.title = "Main" view.backgroundColor = .blue view.addSubview(button) button.translatesAutoresizingMaskIntoConstraints = false button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true button.centerYAnchor.constraint

Change textColor of UINavigationBar “prompt”?

≯℡__Kan透↙ 提交于 2019-12-05 15:48:27
Any (supported) way of doing this? IIRC it usually switches over by itself to a white color at some point when using a "darker than X" tintColor, but we seem to be just on the edge with our scheme. I guess the only way to really do it is to use a custom titleView for each UINavigationItem . You can use a UILabel and try to match the built-in navigation title style as closely as you can, then assign your own text color. It's possible in iOS5: [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, nil]];

Subclassing UINavigationBar in Swift

两盒软妹~` 提交于 2019-12-05 15:36:59
I'm trying to create a custom UINavigationBar class and then use the Storyboard to set it as the class of my UINavigationController 's NavigationBar. Here's the code of my UINavigationBar class: class CustomNavBar: UINavigationBar { override func drawRect(rect: CGRect) { super.drawRect(rect) // Drawing code self.backgroundColor = UIColor.orangeColor() let myLabel = UILabel(frame: CGRect(x: 0, y: 4, width: 600, height: 36)) myLabel.backgroundColor = UIColor.purpleColor() myLabel.textColor = UIColor.yellowColor() myLabel.text = "Custom NavBar!" self.addSubview(myLabel) } } Then, in Interface

iOS7 Facebook NavigationBar Behavior

别等时光非礼了梦想. 提交于 2019-12-05 15:27:24
My App has more or less the same navigation concept as Facebook's / Instagram's iOS7 Apps: A ContainerViewController with 5 tabs, each of which has a NavigationController as it's rootViewController. I'm now trying to reproduce Facebook's navigationBar behavior for the rootViewController of the first tab's navigationController (-> the first 'real' VC, not just a container like NavVC). I was able to implement a hiding/showing navigationBar using the UIScrollView Delegate methods (scrollViewDidScroll:, scrollViewWillBeginDragging:, scrollViewDidEndDragging:) Note: The frame.origin.y of the

Change title of a navigation bar button item

一个人想着一个人 提交于 2019-12-05 14:02:45
let button = UIButton() button.setImage(UIImage(named: "coin_icon"), forState: UIControlState.Normal) button.addTarget(self, action:#selector(Profile.goCoin), forControlEvents: UIControlEvents.TouchDragInside) button.frame=CGRectMake(0, 0, 30, 30) let barButton = UIBarButtonItem(customView: button) self.navigationItem.rightBarButtonItem = barButton My code is this to add a bar button on navigation bar. However, i need to change the title of button in a function func changetitle() { self.navigationItem.rightBarButtonItem?.title = "Change" } I tried this one but didn't work. How can i change the

UINavigationControoller - setNavigationBarHidden:animated: How to sync other animations

二次信任 提交于 2019-12-05 13:48:06
How can I capture the animation curve and speed when I hide the navigation bar programmatically? I would like to sync other animations with this one for a fluid transition :) Stefan Ticu If you check the UINavigationController documentation there is this line: For animated transitions, the duration of the animation is specified by the value in the UINavigationControllerHideShowBarDuration constant. Below is a code snippet for those who would like to take the advice of the accepted answer, but don't know how to go about it :) [self.navigationController setNavigationBarHidden:YES animated:YES];

how to show cancel button of searchbar?

折月煮酒 提交于 2019-12-05 12:57:57
问题 I want to hide the Navigation Bar of my page when the user start editing on the searchbar, I also want to show a cancel button. It is done but my cancel button is not accessible when I bring up the UISearchBar Thanks to All. - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar { self.navigationController.navigationBar.hidden=TRUE; CGRect r=self.view.frame; r.origin.y=-44; r.size.height+=44; self.view.frame=r; searchBar.showsCancelButton=TRUE; } 回答1: Objective C - (void

iOS 11 scroll to top when using large titles doesn't work properly

被刻印的时光 ゝ 提交于 2019-12-05 12:45:33
When using large titles and tapping the status bar to scroll to the top of a UIScrollView or UITableView (probably also UICollectionView , haven't tested this) it always goes a little too far. I have refresh enabled on my TableView and when tapping the status bar it appears like this and stays that way until I tap the screen. I have a ScrollView in another ViewController and if I tap the status bar there it also scrolls a little bit too far, making the navigation bar too tall. This also returns to normal when I tap somewhere or scroll a tiny bit. Normal: After I tapped the status bar: This

Send UIWebView title to UINavigationBar

不想你离开。 提交于 2019-12-05 12:04:10
问题 I am trying to send the UIWebView page Title to UINavigationBar. I would also like it if a user clicks on a link the UINavigationBar shows a back button but if on the home page hide the back button. 回答1: to retrieve the title page into an UIWebView you can use it: myNavigationBar.title = [myWebView stringByEvaluatingJavaScriptFromString:@"document.title"]; If you want to go back you can do that: if ([myWebView canGoBack]){ [myWebView goBack]; } To know if the user has loaded a new page you

iOS 7 detail layout when master has navigation bar prompt

社会主义新天地 提交于 2019-12-05 11:06:00
I run into a layout problem in iOS 7: To reproduce create a simple master-detail-app and insert this line in MasterViewController.m : self.navigationItem.prompt = @"Master"; and this in DetailViewController.m : self.edgesForExtendedLayout = UIRectEdgeNone; Both lines in viewDidLoad . The detail view's frame does not update correctly when the navigation bar shrinks to its normal size. How should I fix this? My current solution to this is to remove the prompt in the master view 's viewWillDisappear: - (void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; self