Hi in the app I'm building using Xcode 9.3.1 I have a navigation item titled "Home". In the next view controller, I have a sign out button in the top right corner, but I also have a "<- Home" button in the top left corner. I want to get rid of the "<- Home" button as it is unnecessary and doesn't conform to Apple's standards. Apparently, you can't delete the left tab bar item aka the (<- Home) button and I don't want to change the global tint as that would also hide the Sign out button I have in the top right corner.
Pic_of_My_Build
To hide back button:
add this in ViewDidload of your Target View controller Race groups
let maskView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 40))
maskView.backgroundColor = .clear
self.navigationItem.leftBarButtonItem = UIBarButtonItem.init(customView: maskView)
try in your viewDidLoad from RaceGroupsViewController
self.navigationItem.hidesBackButton = true
Another option is to change the type segue from show to present modally and set a NavigationController before RaceGroupsViewController
I fixed it by putting the view controller that said "Home" in front of my navigation controller and making the view controller that said "Home" the initial view.
Related
I am displaying a popover (Present as Popover) as a dropdown when the user clicks on nav bar title (which is a label + an image). I was not able to set the nav bar title as popover's anchor view. So for anchor view, I added a clear 1x1 button that sits right below the nav bar (button.top = safe area.top)
I am able to position the popover along the y-axis by changing the y value in sourceRect.
popover?.sourceRect = CGRect(x: 0, y: -10, width: 1, height: 1)
It looks good, except I don't want the arrow in the popover. So I added this line of code.
popover?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
Now, I am not able to position the popover correctly. It doesn't matter what y value I specify in sourceRect, the popover stays at the same place.
What am I doing wrong?
Thanks.
The problem is that that is not how to suppress the arrow. The right way is to provide a custom UIPopoverBackgroundView that doesn’t draw the arrow.
However it would be better not to do this at all. Popovers have arrows. If you don’t want the arrow, don’t use a popover. Write a custom presented view controller instead.
I want to set the right button item to be this:
It has the title and the down image.
But in storyboard, I can not do that:
I only can set one of the title and image, if I set image, I can not set the title, if I set the title, I can not set the image.
I have tried use the UIButton and the Button Bar Item to do it, get the same result.
Some friend know how to do with that?
You can simply add drag UIButton to rightBarItem in storyBoard . and customise that button as per your needs ..
Check View hierarchy after adding UIButton .
you can try this add the custom view to your bar button item
var RightView = UIView(frame: CGRectMake(0, 0, 100, 44))
// you can add in RightView, your title in uilable and your image in imageview
var RightBarButton = UIBarButtonItem(customView: RightView)
self.navigationItem.rightBarButtonItem = RightBarButton
I want to have the Tab Bar at the top of the screen. One post suggested to do the followings (I put the following code in the viewDidLoad() of the UITabBarController) :
CODE
let tabBar = self.tabBar
// yStatusBar indicates the height of the status bar
let yStatusBar = UIApplication.sharedApplication().statusBarFrame.size.height
// Set the size and the position in the screen of the tab bar
tabBar.frame = CGRectMake(0, yStatusBar, tabBar.frame.size.width, tabBar.frame.size.height)
There are 2 problems with this solution:
The bottom of the screen is left with a black region where the tab bar was
The Tab bar covers the view at the top of the screen - the constraints of that view is relative to the device but they should be relative to the Tab bar. However when the screen is designed in the IB there is no Tab bar to relate to.
Is there a way to overcome these problems? P.S. I am new to IOS
let tabBar = self.tabBarController?.tabBar
// Set the size and the position in the screen of the tab bar
tabBar?.frame = CGRect(x: 0, y: self.view.frame.height, width: (tabBar?.frame.size.width)!, height: (tabBar?.frame.size.height)!)
Although it is against the human interface guidelines there exist a hack if you really want to.
You could create a blank UIView in your storyboard (with proper constraints set up) that would essentially be the placeholder for the tabBar when loaded.
You then set top constraints for your other views relative to this view that you have setup.
This works, but probably not best practice to do so
In my view controller I have a UIView (drawer view) that sits below the visible screen with just the top poking out (a tab). This tab can be tapped and the UIView will animate up and fill most of the screen. The view is set like so:
drawerView = DrawerView(frame: CGRect(x: 0, y: UIScreen.mainScreen().bounds.size.height - DrawerView.submitTabHeight, width: UIScreen.mainScreen().bounds.size.width, height: UIScreen.mainScreen().bounds.height*0.75))
drawerView.delegate = self
view.addSubview(drawerView)
Below is a screenshot of the setup:
I have to present this view controller from a tab bar controller. I want to hide the tab when the view controller is loaded and I did this by setting Hide Bottom Bar on Push in the IB. The problem I have now is that when I push the view controller the drawer view is temporarily out of place. It is higher up than it should be by the height of the tab bar (shown by the dotted line on the screen). It then jumps back to the actual position it should be in. Any ideas what I might be doing wrong here? Any pointers on this would be greatly appreciated! Thanks
Just hide the tabbar before pushing the viewcontroller.
if (self.tabBarController) {
self.tabBarController!.tabBar.hidden = true;
}
I'm trying to recreate google inbox's plus button on a UITableView
Here's the image:
I want to recreate the red plus button on the bottom right in a UITableView. I've got an image which is the red button and I've tried just dragging a button onto the storyboard, but it orbits around the contentView. I can't move it to the bottom right.
I also tried adding a transparent UIView as a subview of my table view like so:
let transparentView = UIView(frame: self.view.frame)
transparentView.alpha = 0
let plusButton = UIButton(frame: CGRectMake(50, 50, 50, 50))
plusButton.imageView?.image = UIImage(named: "plus")
transparentView.addSubview(plusButton)
self.view.addSubview(transparentView)
The view just doesn't show up. Not sure whats wrong. Any ideas?
You will have to position it in the superview of your table view:
o View Controller
|
\---o View
|
+---o Red Button
|
\---o Table View
Try using the side bar in Interface Builder to get your red button to the right place in the hierarchy. If you need to insert a parent view to your table view, try using Editor > Embed in > View