Align UItextFields one below the other in interface builder - iphone

How to align 2 textfields one below the other in a tool bar and display a button on the left side (or right side) in the vertical middle of those two fields? Please see the image to know what I am talking about.
http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/mobilehig/art/ui_textfields.jpg

What makes you think that's a toolbar?
It looks like a UIView with a background, that's added on top of the map view. You can create a UIView, adjust two text fields and a button to look like that in Interface Builder.

Related

Why Xcode Storyboard preview and emulator button texts are not compatible?

I am trying to drag and drop buttons to the storyboard. The buttons seem good in my storyboard and preview like the following;
However, when I run the simulator, the button texts seem like the following;
Why the buttons are not shown to fit in the buttons of the simulator and how can I fix this?
Note: Preview and device types are iPhone13 Pro.
The iOS 15 / Xcode 13 style buttons are highly dependent on auto-layout.
Based on your screen-shots, it doesn't look like you've given the buttons any constraints.
You do NOT need to set widths or heights, but you DO want to set at least horizontal and vertical position constraints.
So, constrain all 4 of your buttons centered horizontally, and constrain:
First button Top to view Top (safe area)
Second button Top to First button Bottom
Third button Top to Second button Bottom
Fourth button Top to Third button Bottom
Then you should see them laid-out correctly at run-time.
I think it's because of the auto layout constraints. I am not very familiar with storyboards, if you don't set width of the view component, it seems fine on the storyboard but when compiling the view it actually has default size.
Try to set some constraints for width. Maybe it would help.
The first thing you need to do is to create identical buttons with identical size and with identical font size.
As you can see in your project, the buttons have different sizes, but the text is the same size in all buttons.
To make it faster - you can create one button and make a copy with option + drag’and’drop…
Then, you can put them in a Stack View. So, it will be easier for you to work with them in the future.
Select all buttons and make a Stack View...
https://i.stack.imgur.com/QLTJP.png
https://i.stack.imgur.com/OlOia.png
After that, resize your Stack View like you want.
Then, tap on a Stack View and clear the constraints.
https://i.stack.imgur.com/1pMT8.png
Fix the dimensions like this. But, without “Constrain to mergins”.
https://i.stack.imgur.com/8HKKF
After that, make for the Stack View - horizontally and vertically position in your storyboard.
https://i.stack.imgur.com/a29wL.png
The result is…
https://i.stack.imgur.com/mvQjg.png
Hope it’s break your problem! :)

How to add two custom rightBarButtonItems without a margin between them?

I create UIToolbar with interface builder and want to add two custom right buttons, but without a space between them. I don't want solution to reset a margin from the right edge, because I found it here but want only reset margin between buttons.
How should I do this?
Thanks.
Instead of a button, use an UISegmentedControl and set its momentary property to yes.
Add one segment for each button you want (in this case two segments)
Then add an IBAction and use a switch to know what index has been selected.
Index 0 first button, index 1 second button.
Create a bar button item with a custom view where that custom view has 2 UIButtons as subviews. In this way you can exactly size and position the buttons as you require.
To adjust space between UIBarButtonItem's you can use a UIBarButtonItem with style UIBarButtonSystemItemFixedSpace and setting its width property.
You can move items closer to eachother than the default spacing by setting the width of the spacer item to be a negative value.
One thing to consider is future-proofing whichever solution you choose. Buttons in iOS6 have nice borders and shading. They may not in the near future...

iOS Interface Builder lock views to right of their table cells

In the form pictured below, as you can see, all of the items are aligned to the right in portrait mode. However, in landscape mode, the text box and switch do not move to the right with the detail items. The detail cells use an apple template, while the ones with the text box and switch are custom cells. How do I set it up in interface builder so that the switch and text boxes move over to the right?
I've been messing with this for a while with no success and haven't found any useful information googling.
If you're using a custom cell, you need to set the autosizing mask to keep the right margin fixed on the views you want to align right, something like this:

ToolBar Icons Are not Centered

I've implemented in my app a ToolBar. How do I control the buttons scale? I want them to be stretched from left to right. In the Interface Builder ---> ToolBar Attributes there is a field called "Mode" (where I can select between "Scale to Fit", "Aspect Fit" etc...) but it doesn't change anything.
Do I have to create the buttons' icons in a very specific size (if so, what should be the size for 6 buttons?) or can I set them in the Interface Builder?
If you're working in Interface Builder, you'll find an object in the Library called Flexible Space Bar Button Item. You just drag and place one of these objects in between any adjacent buttons, so that the objects on the toolbar end up ordered something like:
button-fsbbi-button-fsbbi-button-fsbbi-button
These objects act as springs that keep your buttons equally spaced apart.

Custom UIToolBar from Images

I need to create a UIToolbar object that uses an image for the background. Most of the buttons are images as well, and rectangular. One button, however, is round and overlaps the toolbar like the Start button on the Windows task bar. See below.
I know that I will need to subclass the UIToolbar to paint the image for the toolbar -- I think. If so, does anyone have example code showing how to do this?
Furthermore, does anyone have any ideas on how to implement the larger round button? I'm thinking of another custom subclass for this, but not sure if there might be an easier way.
I can have the art guys chop the image anyway needed, which I'm sure the round button will need to be chopped some how.
Any ideas or sample code?
alt text http://iphone.sophtware.com/toolbar.png
Maybe you'll find some inspiration at this tutorial : Recreating The Raised Center Tab Bar Button of Instagram, DailyBooth & Path
For the color, you can experiment with the tintColor property.
As for the rest, UIToolbar is not designed for this. You will need a custom component (probably based on UIView).
I think it is possible but hard.
Override the drawRect method of the toolbar to draw the whole image. Then add left and right buttons.
For the round button you can add one invisible button on the bottom middle of the View and another invisible button in the middle of toolbar. Of course, you can try to use the views instead of the buttons and track the user interaction manually.