I'm building a netflix clone. In configuring the nav bar, I keep running into an odd error that I can't seem to find a solution for anywhere: I want my nav bar to contain a "leftBarButtonItem" that houses a UIImage of the Netflix logo w a transparent background (located in my assets folder). But when I attempt to do this, the alignment is always off; as if padding is being added to either side of the image (see screenshots A & B below).
I've tried:
For added context, you can follow the link below to my github repo. The problematic code is in Controllers > HomeViewController at line 33
Github Link: https://github.com/nlpope/Netflix-Clone
Failure Screenshots:
Partial-Success Screenshots:
I got it; The issue was with the size of the netflix logo in the UIBarButtonItem. Before, I was directly assigning the netflix UIImage to navigationItem.leftBarButtonItem via the preset UIBarButtonItem(image:,style:,target:,action:),
instead I should have done this indirctly by passing a customView parameter:
This allowed me to set width and height constraints to the barButtonItem without the custom view (netflix logo) affecting it negatively (because it's just a custom view passed through what we're actually editing