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").
Related
I have a custom #IBDesignable UIButton. I use several of them on a screen in the Storyboard file and they are central to the whole flow of the app. They all appear in the Guide as "Button":
"Button"s in guide
Seeing the actual title would be a whole lot easier in managing the Storyboard (although of course has no effect on actual runtime). I'd like to set the title to an #IBInspectable label text I'm using:
Their attribute Inspector
I'm using my own label text instead of the regular button title because it's layout and format is special. If I set the button title it shows up in the middle over the real title.
Ideally I want to set the guide "title" to my label. I couldn't find anything anywhere on how to do this. Otherwise, is there some work around trick to use the Button Label? Keep in mind this is just to make the Storyboard less confusing for others to see and use.
Thanks!
You can always slow double click each button (in the Document Outline (the left pane (your first picture))). It'll let you rename it right there.
By "slow double click" I mean, click to select, wait a sec, click again (without moving the mouse).
I'm only familiar with The Document Outline automatically naming things when you provide referencing outlets (control dragging to a .swift file). They'll take on the names of the variables you're dragging them to (even so far as formatting camel case with spaces and caps for you). Otherwise, in your case, you're probably going to have to manually name each one.
You can "name" your elements by filling in the Label field in the Identity Inspector pane:
As you see, I have a normal UIButton, and I put "Button One" in the Label field... so it shows up as "Button One" in the outline pane.
I'm doing a the Ray Wanderlich iOS Appprentice and we are right now working with AutoLayout.
I'm asked to add some constraints to the this particular Table View and I can do so.
What I can't do is modify the "Update Frames" behavior. In this particular case, the book asks me to set it to None.
I can tell you that his is not the default behavior because my label has shrunk as per the warning in the book—see attached warning and image.
Note: If you had set Update Frames to “Items of New Constraints”, then Interface Builder would have moved the label to where the dotted
box is. That’s why you left it set to None because you didn’t want it
to do that here.
What can I do to do as the tutorial intends?
So either you click on the round arrow:
or by simply using this shortkey:
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
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.
How do I solve such warning? What does it mean in most of the cases?
When I click on it, there is nothing highlighted on my Interface Builder (it just zooms in on some area between 2 view controllers).
You have a UIImageView with Highlighted set to true in Xcode. Xcode tells you that the value is for WYSIWYG but won't work at runtime.
After looking at warning message details I got to know, but still there was no way, I could find particular Image is having highlighted="YES"
Perfect Trick suggested by #Keller in Accepted answer's comment.
Just right click your Storyboard --> Open As --> Source Code.
search for
highlighted="YES
Just set YES to NO.
or event if you look carefully code around searched string, you can get in which ViewController's Scene particular ImageView.
Thanks to #Keller
Right click on your Storyboard -> Open as -> Source Code.
Search for highlighted = "YES".
Check the name of the image.
Find the image on the Storyboard.
Click the image, go to Show the Attributes inspector.
Uncheck the Highlighted option
Highlighted image