I would like to show options to choose in my View. I did not found a control for that. Any suggestion howto do that ?
You must use 3 different buttons for the check box,now set different tag for the buttons and set default and selected image for the button.
Related
I am trying a lot of code and it's nothing is working for me. I need to make four radio buttons with swift when I show the question for the user to choose one of radio buttons.
Sadly, there's not a built in way to do this with Swift, but it's easy enough to code out. I'd personally recommend using this Git project, as I've heard good things about it.
If you'd like to built a radio button from scratch, I'd suggest looking a making a check button by using a regular button with a UIControlStateSelected triggering a check img, and then set the layer.cornerRadius (after setting the clipsToBounds = true of course) of your button to half its width to produce a circle!
You can create your own login by using a mutabledictionary with button tag as key for dictionary. Add green/selected image for selcted button & set "yes" value for key (button tag) in dictionary for selected button & "no" value for other button's tag.
I have an example for the same but in Objective -C
The UIControl that offers the closest behavior from radio button in swift iOS is the UISegmentedControl, take a look at the reference.
Here's apple's guidelines for mobile controls.
Some quotes from this article :
Use a segmented control to offer choices that are closely related but mutually exclusive.
A segmented control:
Consists of two or more segments whose widths are proportional, based on the total number of segments
Can display text or images
I want to create the following selection button to pick from the two options "Salary" and "Hourly Wage".
I have images for when either (left or right) option are selected.
What UI element in iOS can I use to create this? Looked into a Switch but did not see an option on how to set custom backgrounds.
Obv in code I will need to know which option is selected also. Should I be treating these as two separate UIButtons right next to each other?
The control you are looking for is a UISegmentedControl - see the Apple Docs.
Is there an option for a button/image to set, that it will always be shown on top? So I have 2 buttons and want to add an image. But the image covers the two buttons and I have no idea how I could get the image in the background or the buttons in the front.
BTW: I´m fairly new to xcode and programming...
Use the xCode top menu item Editor->Arrange. There you have options to handle z index for controls.
What I did was, to have two button one for the label and one for the image and when one is clicked it propagates the message to the other and does the action depending on which one was clicked.
What I'm trying to do is simple: bring a label in front of an image within a subview.
But all of the options for arranging are disabled/un-selectable when my label is selected. I find this happens often.
What could be the reason that I'm almost never allowed to change the z-axis of my objects in the Arrange menu? Is it a better practice to avoid this feature and set the order of views programmatically?
It can depend on how you have selected the label (similar to how the label can only be moved with the keyboard when selected in some ways).
A simple alternative is to look at the list of view in the pane on the left and to drag the views up and down to change the order.
It happens sometimes. In that situation, click the view or image you want to send back then you will see little square box at the edges of image from which you can re size your image, Just click on it once and then go to Editor > Arrange > Choose option according your need.
I think I've seen this kind of button before, and now I need one.
A button like the one below who's label can be changed to whatever number I need (from 2 to 10 for example).
I have a feeling that this exists by default in iOS SDK but I can't seem to find it.
Does it exist by default or do I have to create it myself?
Thanks!
Its easy to replicate. Add a new RoundRectButton in interface builder, then in the attributes inspector change the type to Custom. Set the BackgroundImage to an image similar to above, and then set the Title to the number. By default the title will centered in the button, but you can use the Inset options in the attributes inspector and nudge the title in and down using the Top and Left inset attributes.
No, it's not a default item as far as I know. You can see all the default items in the Apple Human Interface Guidelines (see "System-Provided Buttons and Icons").