How can i make a label multiline with a button next to it. Multiline works fine without the button. How should i set the trailing constant for button so that it moves along with the length of the label. Please see the screenshots.
Increasing the text moves my button away.
Any advice is appreciated. Thanks!
You need to set the right constraint for the button with its superview. Beside, the size for the button is matter as well.
In your case, the code is really simple, let's say I write it using Snapkit autolayout kit:
attendeeLabel.snp.makeConstraints { make in
make.top.centerY.bottom.equalToSuperview()
make.left.equalToSuperview().offset(15)
}
cancelButton.snp.makeConstraints { make in
make.top.equalTo(attendeeLabel.snp.top).offset(10)
make.left.equalTo(attendeeLabel.snp.right).offset(5)
make.right.lessThanOrEqualToSuperview() // <-- this will keep the button on the right side of the label, but will not exceed the superview
make.width.height.equalTo(22) // <-- this is the size of the close button
}
Please follow my steps
Step1:
Add a label and button.
Step2:
Step3:
step4:
step5:
Add other constraints according to your requirement.
It may helps you. Thank you.
Related
Does anyone encounter the same issue with the Photoshop?
I have been trying to change my wording sizes, every time I select the text layer, highlight and click the size/fonts (image below), and scroll my mouse to chose, the text on the layer does not change and no preview. Unless I select it and it changes.
It is difficult and wasting time to actually try one by one manually rather than scrolling mouse and see the preview. Do I need to do some setting changes? Help please.
Press and Hold the left mouse button on the 'tT' icon of the fontsize and drag it left or right to decrease or increase the size of the font with a live preview.
I hope this helped :)
I want to basically do this: ETA info under the button with a car image
How can I add text just at the bottom of the button? Thanks in advance.
I have found the solution a long time ago but forgot to mention it here.
Here it is:
Just create a Vertical StackView, set its alignment as Center and distribution as Fill, and put your label and image in it. Make your label hidden at first. Assign the StackView as the leftCalloutAccessoryView. When you got the ETA info, just make the label unhidden inside an animation code.
That's it! It will behave just like in the Apple's Map app.
experts!
Today started to build Apple Watch version for my CelebrateMore! app and can't solve one issue. I have 2 interface controllers - Page-based kind. As soon as I set segue to "next page" from first to second, my first interface controller starts to scroll much more than before.
Screenshot from Storyboard:
Screenshot from simulator during scrolling:
Screenshot from simulator if I remove next page segue and scroll:
Already from scrollbar it can be seen, that there is a lot of empty content if "next page" is used. Does anyone has some idea, how to solve this, how to avoid "the long after content scrolling" issue?
I've struggled with the same issue for several hours until I decided to give it up for a while and focus on filling the labels with actual data at runtime. After I added some code to the main initialisation methods of WKInterfaceController ((void)awakeWithContext:(id)context {} and/or (void)willActivate {} ), this scrolling issue magically disappeared. Try to set the text of one or all the labels in your interface in code in one of the 2 methods mentioned above and see if the scrolling problem gets fixed:
[self.label setText:#"Some text.."];
It worked in my case.
Due to low reputation I cannot upvote: The solution of setting the text of a label worked for me too. I set an empty text first, then load the data and update the label there again once the request is successful. It works and calculates the height of the scroll view correctly.
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
//enable correct scroll height
self.titleLabel.setText("")
self.loadData()
}
I used a different way to work around it.
First put a group in the InterfaceController, and assign fixed height to it, then put other components inside the group.
To make the group occupy full screen, its height for 38mm should be set to about 142 point and for 42mm should be set to about 165 point. You can use the plus sign next to the value to enter these values for the 2 models.
I am unable to center a checkbox inside a checkbox cell. Tried programmatically and over IB but without luck.
To reproduce add a NSTableView and in this add a NSCheckboxCell. edit the text of the checkbox to an empty text. Now try to center the box with the alignment button inside the cell. it will stay at the very left.
How can this be done? I would need to do it programmatically so if the answer is for a pro grammatical solution its better. If it is in IB then I am ok anyway and will find the programmatical version myself.
IB-Version would be to set the 'Position' to be centred.
Change it to be the value in the screenshot.
I'm currently looking for a non-IB-Solution but the docs don't say anything ...
The non IB answer is to set the image position.
i.e. swift would be "btnCheck.imagePosition = .ImageOnly"
and ObjC would be [btnCell setImagePosition:NSImageOnly]
I am designing an editable UITableViewCell*. In the normal state, my cell should look like the portion of this image above the red line.
When users click [Edit...], the controls letting the user change the settings will show up, and the text of the [Edit...] button will become [Done]. Clicking [Done] will hide the portion below the red line, and change the text on the button back to [Edit...].
I am trying to achieve this effect by changing the height of the row in the delegate. When the cell is in edit mode, it's returning the full height; when the cell is not in edit mode, the height of the upper portion from the red line on is returned. Unfortunately, when I do that, the edit controls "slide up", obscuring the rest of the cell. I am fixing this by making these controls invisible in the edit mode, but I think there should be a better solution.
Are there settings that I could apply to the controls in order to let me cut off the bottom, clipping the content below the red line?
* I am using Interface Builder to design my cell, in case it matters.
In your xib - just turn on the top strut
This is working for me. To make it smoothly expand and contract you'll need to use the trick of an empty beginUpdates/endUpdates call
[tableView beginUpdates];
[tableView endUpdates];