How to have a Touch Bar button which is image only? - swift

Adding touch bar buttons into touch bar of macOS, with images of size 80x60, ends up like this:
The button has been scaled to 40x30, but instead of a button filled up by image, it has the left/right padding on the side of button. Is it possible to have actual size of touch bar buttons without the padding?

You have to use Image Button from object library, but you have to include it into the Touch Bar View which you can find in object library.
Output looks like this:

Related

UIBarButtonItem Custom Image is Stretched (Xcode)

I'm creating a side menu in Xcode, and to open it I'm using a navigation view controller like the following:
I need the left bar button item to be on the left.
I added a left bar button item. Without changing it to a custom image, it is aligned to the left, as desired. When I change it to the custom image (the three lines) it stretches and aligns itself in the center. I have not written any code for this view controller yet, so none exists for the bar button item.
How can I get this aligned to the left as it should be? (Above the "Home" text).
Thanks for any help.
This is because your menu icon size is bigger.I have added two images one is with 64*64 px size which is perfect and in another icon with 512*512 px size
Hope it will help.Thank you.
You can’t use any image size for UIKit tab bar or navigation items.
Please read this guideline from Apple:
https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/custom-icons/

UIBarButton Item with Image Covers UINavigationBar Title

When I try to add a RIGHT bar button item with an image in it (either programatically or via the storyboard), it ends up centred and covers the title (see images below). Why is this?

Slide view while touching button - IOS

I'm trying to implement a view that includes social buttons.In normal state, it will be partially hide and only the "Opciones" button and the upper line is shown. This view will be shown when user touches button "Opciones" (touch gesture), then it will unhide and be shown using sliding effect until the final position that is included in the attached image.
I'm wondering which kind of control and animation I have to use.
Many thanks.

UIToolbar and Flexable/Fixed bar button items

I have a toolbar, where I want to have one UIBarButtonItem centered and have another on the very right. However when I add the button on the right, my centered button gets shifted further to the left (see attached). I can't figure out how to get this resolved without using code (I would like to use interface builder only). Any ideas?
To do this in just IB, add a fixed bar button item to the very left of the bar that's the exact same width of the 'switch camera' button, followed by a flexible button, your camera icon, another flexible space, and the switch camera.
So it would look like:
|--fixed space--||--flexible space--||Camera Button||--flexible space--||switch camera|

UIBarButtonItem in middle of navbar?

I have created a flexible navigation bar in my app that will show custom buttons on the left, right, and in the middle. So far I have got working:
Right/Left/Middle - Custom Image and/or Text
Right/Left - Normal looking button with custom Image in it
Right/Left - Normal looking button with custom Text in it
By 'normal looking' I mean the default UIBarButtonItemStyle- just a nice shiny button.
My question is, how can I achieve the same look in the MIDDLE of the nav bar? I can do custom/text images by just creating a custom UIButton, and on the right / left I create a UIBarButtonItem from it, but in the middle I just add the UIButton view as a subview of the navbar.
I can't add a UIBarButtonItem to the navbar as a subview, and any UIButton I create doesn't look like a UIBarButtonItem.
The only workaround I can think of is to use a stretchable custom image that I steal from a screenshot. I'd rather avoid doing it this way. Am I missing something?
*********** UPDATE **************
The open source library Three20 will allow you to create UIButtons that look like UIBarButtonItems. Then you can add them to the bar view either by placing manually as a subview or by setting the title view.
I never understood why they didn't make UIBarButtonItems derive from UIViews (or even better, UIButtons) so they could be used elsewhere.
Sounds like you're on the right track, but need better artwork :-) You can get a large number of iPhone UI components in a Photoshop .PSD file from here. They have pre-rendered bar buttons which you can use as a base for a standard UIButton image. If you have Photoshop (or a decent drawing program) you can stretch the buttons from the middle to fit your size without getting the corners distorted. Just add the label and you should be good to go.
Put a flexible region on the left and right, they will offset each other causing anything between them to be centered