UIViewControllerRepresentable: Navigation Title and Bar Button Items Ignored in NavigationView

Solved! Problem and Expectation SwiftUI uses a UINavigationController under the hood. So, if I push a UIViewController onto a SwiftUI NavigationView using UIViewControllerRepresentable, then I would expect the navigation item and toolbar items of that view controller to be used by said navigation controller. As I mention above, they are ignored. Root Cause It turns … Read more

How to properly position the back button in iOS7

EDIT I think I might have found the trick (in iOS 7 Design Resource — UIKit User Interface Catalog.) Under Bar Button Items Note that a bar button image will be automatically rendered as a template image within a navigation bar, unless you explicitly set its rendering mode to UIImageRenderingModeAlwaysOriginal. For more information, see Template … Read more

How to set back button text in iOS navigation controller?

The back button belongs to the previous view controller, not the one currently presented on screen. To modify the back button you should update it before pushing, on the view controller that initiated the segue: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { let backItem = UIBarButtonItem() backItem.title = “Something Else” navigationItem.backBarButtonItem = backItem // This … Read more

Add subtitle under the title in navigation bar controller in Xcode

Here is my version using a stack view on an extension. extension UINavigationItem { func setTitle(title:String, subtitle:String) { let one = UILabel() one.text = title one.font = UIFont.systemFont(ofSize: 17) one.sizeToFit() let two = UILabel() two.text = subtitle two.font = UIFont.systemFont(ofSize: 12) two.textAlignment = .center two.sizeToFit() let stackView = UIStackView(arrangedSubviews: [one, two]) stackView.distribution = .equalCentering stackView.axis … Read more

How to change the UINavigationController back button name?

If you wish to do this programmatically, it can be done like this: Objective-C UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@”Custom” style:UIBarButtonItemStyleBordered target:nil action:nil]; [self.navigationItem setBackBarButtonItem:backItem]; Swift let backItem = UIBarButtonItem(title: “Custom”, style: .Bordered, target: nil, action: nil) navigationItem.backBarButtonItem = backItem However, if you prefer using Interface Builder, just select the UINavigationItem that you wish to … Read more

UINavigationBar multi-line title

Set the titleView property of the UINavigationItem. For example, in the view controller’s viewDidLoad method you could do something like: UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 480, 44)]; label.backgroundColor = [UIColor clearColor]; label.numberOfLines = 2; label.font = [UIFont boldSystemFontOfSize: 14.0f]; label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5]; label.textAlignment = UITextAlignmentCenter; label.textColor = [UIColor whiteColor]; label.text = … Read more

UIBarButtonItem with custom view not properly aligned on iOS 7 when used as left or right navigation bar items

Works until iOS11! You can use negative flexible spaces and rightBarButtonItems property instead of rightBarButtonItem: UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; spacer.width = -10; // for example shift right bar button to the right self.navigationItem.rightBarButtonItems = @[spacer, yourBarButton];

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)