I would like to have two labels in my tableview.
but the label resize option is disabled.
How to have the two labels horizontally?
Select UIlabel instead of the cell and then you can set Auto resize like follow.
You may need AutoLayout and Custom Tableview Call. Use two different labels, e.g. one for username (left aligned text) and another for garbage text (right aligned text).
Now, set Content Compression Resistance Priority for one of both label, according to your requirement for data visibility when there is long texts in user name.
Look at these snapshots:
Labels with default content compression resistance priority
I changed content compression resistance priority for label blablabla blablabla, from 750 to 749.
Result is:
For more details see Apple document: Setting Content-Hugging and Compression-Resistance Priorities
Drag a horizontal UIStackView from object library and set it's constraints like this inside the cell
//
drag 2 labels inside it and make the distribution .FillEqually
//
Are you sure you have selected Label?
If you know about Layout constraints, it will be easier than this auto resizer.
Label 1==> Set Leading, Top & Bottom constraints to SuperView. Set Trailing constraint to Label2.
Label2==> Set Trailing, Top & Bottom constraints to SuperView. Set Trailing constraint to Label2.
Now, after this, it will show Red error arrow. Now, you have to decide which Lable width is a priority. After deciding, select that Lable and set Horizontal Content Hugging to 251(High) and Comprehensive to 751(High). Also, change lower priority label Content Hugging and Comprehensive to 249 and 749 respectively. Now, Red error arrow will not be shown and in the cell it will show all text in both labels without and cut.
if you want a easy and quick fix for it, implement a stack view inside the tableview cell. You can change the stackview as you want and also you dont have to worry about applying constraints.
Related
I am trying to build a scene in my 2D game which has a panel whose elements are arranged as in this image:
The ScrollRect should dynamically add rows after users provide values to the InputField, select an option from the Dropdown, and then click the Button. This all works fine, except that the viewable area of for the ScrollRect has the same vertical size as its siblings within the parent panel.
This happens because the GridLayoutGroup of the parent panel requires the child cell sizes to be specified, and if I specify a value which makes sense for the top two panels it is too short for the ScrollRect. Putting a ContentSizeFitter on the parent panel does not help (also, despite Unity warning against it, there is a ContentSizeFitter on the content of the ScrollRect since without one the newly added rows will not appear when scrolling).
So my question is:
what do I need to do to allow the vertical sizing of the children of the top level panel to be based on their sizes, when one child's vertical size will change dynamically?
Thanks!
For grid layout you cannot control the cell sizes dynamically . Instead you can use horizantal / vertical layout groups where you can find an option control child size . And as mentioned in above ans add Layout element to child component and adjust the sizes
Both #Programmer and #Salma572 answers are true. If you want that size to be a fixed number or pixels, use a LayoutElement. However, It doesn't seem you can use a scale (in percent) or anything else dynamic.
It's a shame but you'll probably need to write a script.
It is possible. Attach Layout Element component to each child GameObject. You can then dynamically change the size of each child GameObject by modifying the Layout Element's Preferred Width and Height variable.
I have a button inside a horizontal stack view and am trying to give it a border using the Runtime Attributes in Xcode. Here is what my storyboard looks like:
When I run my app the text has no padding so the border fits very tight:
Is there any way to make the border of the button fit a bit looser? I can't seem to make the UIButton bigger since it's in a stack view...
you can look at lowering the content hugging priority of the add button as both are UIButtons and have same compression resistance and content hugging priority and stack view algorithm in such cases stretches the leftmost view.
You have to set a width constraint on the button.
I use a NSStackView to dynamically (added by code) display other NSViews, everything works so far, but the sub views are to small.
They try to be as small as possible, regardless the constrains, if i resize the views in IB, they scale correctly
The Header with the hide button does not fill the available space:
I did set the translatesAutoresizingMaskIntoConstraints property to false on the stackview and all subviews
Well, it's hard to know for sure without more information, but the most likely cause is that the horizontal content hugging priority of the labels is higher than the horizontal hugging priority of the stack view. (Note: the former is a general property of all views while the latter is a stack-view-specific property.)
You also need to have constraints between the stack view and its superview to make the stack view stretch the full width. For example, leading and trailing space constraints.
This is quite old, but in modern times I have found that if you set the alignment to width, everything magically works.
stackView.orientation = .vertical
stackView.alignment = .width
stackView.addArrangedSubview(nowFullWidthSubview)
I'm trying to build a segmented control much like the Bold/Italic/Underline control in TextEdit.
Is there a way to set a custom attributed string for each segment? [set attributedStringValue:] on the cell had no effect (there's no way to set per segment anyway).
If I have to resort to custom drawing, how can I reproduce the inset/blue highlight in the selected state?
Example:
I think these are all icons you need to pre-create and set in the segmented control. Custom drawing would be another option, but I think simply using 3 icons (plus their hires variants) is more flexible.
For custom drawing you'd use an NSAttributedString where you set font and color. Draw it twice, once in white with one pixel vertical offset and and once in blue/black.
In the view propreties I set Grid - Dashes and Dots , color Black. But the grids are only horizontally. I want both vertical and horizontal.
The header style is Beveled. Thanks!
Native Notes applications cannot produce vertical dash-dots grids to simulate a grid. A View in Notes is record (or document) oriented. The grid setting in the view appears in version 8+. I tested dash-dot and it appears to be there, if you increase your line height it should be visible. The dash dots appear to be standard and not variable to font size.
It depends on the first column of the view, if it's not categorized, both vertical and horizontal grids are shown. As soon as you change the column to categorized, the view only shows the horizontal grids.