Xcode Button image top text below in a button not in code - ios

I create a button set image title like below picture.
I want
image
title
image on the top title below is it possible without any code?
I cant just use insets because to another size will wrong

Adjust both the title insets and the image insets.
It will need some calculations, and auto layout will probably screw it up ;)
Probably better to create a subclass of UIButton with a .xib
click the link to view my screenshot

Related

Customising UIBarButton Item Image

So I am trying to customize a bar button item for this slideoutmenu I am creating. I want it to be a particular image. However I am having trouble doing this. Whenever I try to change the image programatically by saying
menuButton.image = UIImage(named: "myImage.png")
It appears to be all stretched. Whenever I tell it to be set to an image using the attribute inspector, it will do the same thing, and I am unable to resize it in the Main Storyboard and interface builder. I imagine the fix to be simple, but I am unable to figure it out. Is there possibly a way to customize the size of the navigation controller to give it more room? Does anybody have any ideas?
I misunderstood the question originally. It sounds like what you are asking is how you resize the image, because it's all stretched out. It might take a little adjusting, but you can set the image insets on the UIBarButtonItem programmatically:
menuButton.imageInsets = UIEdgeInsetsMake(5, 5, 5, 5)
This is just telling the button to draw the image inset 5pts from the top, 5pts from the left, 5pts from the bottom, and 5pts from the right. You can tweak those values until it looks how you wish.

Center UIButton with image next to it

I'm trying to create a UIButton where the facebook icon is a part of the centering, however i can't seem to figure out how to make it part of the centering process. So far i've just created a UIButton with the text. I could just create a image next to it, however then it will not be part of the centering.
You can easily set image and title both for your button for different control state like normal,selected or highlighted etc.
So, set your image and title to your button from storyboard or programmatically there is no need to take separate imageview for image.
You can set edge insets for title and image both from interface builder or programmatically. you can manage top or bottom edge insets for title and image of button to manage it's vertical appearance!
check screen shot below,
Update : (as asked in comment)
For example,
this is the setup for my back button with image!
Provide button title and image for normal state. Then just change the left inset for image as per image

In Swift, how to customize the more menu on a tab bar?

I'm trying to change the back ground and size of the cells but on the more menu but am not sure how to do so. Here is what it looks like now:
I want to add a ui image as a backgrounds as well as add a ui image as a background to each cell so it will look like this:
I saw an old post about this on Stack Overflow but it was 7 years old. Does anyone know how to change the more menu in Swift?
In storyboard
1) add a uiImageView to the ViewControll or TableViewControll that you are using. set Constraint UImageView to SuperView as equal width,equal length,central horizontally and central vertically.
set outlet to access.
2) set tableview background to clear colour in attribute property
3)in tableview cell add a UIImageView and set the same equal width, length ,central horizontal and central vertical to contentView.
cell.background colour should be clear .
based on tab you should change the background image in tableview cell imageView in cellforIndexMethod.
you can change the background image of mainBackground in viewDidLoad or viewDidAppear based on the tab

iOS/Swift: Dynamically Resize a Toolbar

I'm trying to make an app with a toolbar that can be resized. Basically, the toolbar can alternate between being at the bottom of the view and being at the top. When a button is pressed, it switches from one to the other. The problem is that when it is at the top, I want the size of the toolbar to expand to accommodate the status bar, but I don't know how to do this.
I've seen some solutions for changing the toolbar size but they all seem static and not something that can be changed with the tap of a button. Any suggestions on how to do this? Perhaps a different solution altogether?
You can use a normal UIView and customize it so it looks like a UIToolbar, then just set constraints using AutoLayout and animate the height-constraint.

Is there a fast way (keyboard shortcut, etc...) to auto adjust button size to match image size using storyboards?

When I add an image to a button, I often have to look back at the image to get the widht and height, then back to interface builder and set the button width and height to match the image.
Is there a key shortcut or something that will set the width and height of the button automatically to match that of the image?
This question is regarding storyboards in xcode specifically.
Im aware that it can be done in code, not asking about that...
In Interface Builder use menu Editor/Size To Fit Content. Shortcut Cmd+=.
You need the button selected. If that option is greyed out, deselect, and reselect the button again.

Resources