How to expand UIView and move other components when expanded - swift

I have a view Controller that contains filter_View
and a tableView_Players
.
When I press the button "Filter la recherche"
I want the Filter_View to expand this way
and results moving the tableview down
.
How to do that ? thanks in advance :)

If you are using AutoLayout, do following :
1) set vertical spacing from tableView to filterView.
2) set Height Constraint of filterView and set its outlet.
3) Initially that height constraint e.g. heightOfFilterview.constant = x
4) While clicking filter la button set heightOfFilterView.constant = y (Whatever you want).

Related

Is there a way to resize a UIButton in Xcode?

How do I get the 0 width to be equal size with 1 and 2
( . ) to be equal width as 3 and = to be equal width with +?
I can't drag the white square (When clicking the UI button) to resize them.
Screenshot of my storyboard:
Follow Steps
Focus on stack view contain the elements "0 . ="
select ". =" element and embed into a stack view
StackView properties must be "Alignment = Fill", "Distribution = Fill Equally" and "Spacing" as per other elements
Option1
Set the StackView to Distribution Fill and then control drag the 0 Button onto the . Button. Select Equal Widths and then set the Multiplier (times 2 since it should be twice the size) in the Size Inspector.
Option2
Put the .Button and the = Button in an equally filled StackView and then the 0 Button and the StackView in another equally filled StackView. This is probably the better option if it's a 50-50 distribution.

swift: TableViewCell doesn't update constraints until scrolling

i have a tableviewCell containing 2 labels.
The right one has a fixed width and fixed trailing space to superview and the left one a fixed leading space to superview and trailing to right label.
Sometimes i only need the the left label and in this case i want the left one to have a fixed trailing space to superview instead. So, i created a second inactive constraint and do this in my code:
if(entry.right.isEmpty) {
tableCell?.longConstraint.isActive = true
tableCell?.shortConstraint.isActive = false
tableCell?.rightLabel.isHidden = true
} else {
tableCell?.longConstraint.isActive = false
tableCell?.shortConstraint.isActive = true
tableCell?.rightLabel.isHidden = false
}
but when i load the table all displayed cells have the default constraint active and only after scolling out of view and in again, they are displayed correctly.
For an easy way you can embed them inside a horizontal UIStackview and set
self.rightlb.isHidden = true
and it will disappear with no width automatically , also in your current code make sure
tableCell?.layoutIfNeeded()
after you change the constraints
Try adding this code after adjusting constraints programmatically
tableCell?.setNeedsLayout()
tableCell?.layoutIfNeeded()
Hope this works

how to set textfield size fix macos swift

I have one textfield "A" with width 150. but whenever I am passing more characters to textfield "A", it is getting overlapped on other textfield "B" characters.
I want textfield "A" to be fixed size and scrollable(mostly right and left).
Thanks in advance.
You should use Auto-Layeout in your storybook. Set fixed width, trailing space and leading space to your text field.
I have added the Auto-Layeouts to my textfields and I have followed below steps:
1) Selected the label.
2) Go to attributes inspector.
3) Select 'Line Breaks' and choose an option Truncate Tail
4) now I can see the text without overlapping with another textField.
Note: But still I am not able to view/Scoll the full text.
Just found this piece of code. It might help you
scrollView.hasHorizontalScroller = true
textView.maxSize = NSMakeSize(CGFloat(FLT_MAX), CGFloat(FLT_MAX))
textView.isHorizontallyResizable = true
textView.textContainer?.widthTracksTextView = false
textView.textContainer?.containerSize = NSMakeSize(CGFloat(FLT_MAX), CGFloat(FLT_MAX))

How to use the full width when an UI element is invisible in iphone?

I have a label and a button like in the above picture. I like the label to use full width when I click on hide button.
I tried setting the width to 0, how ever it does not change the label with. Is this correct? or is there a better way to do this ?
blockingButton.frame = CGRectMake(blockingButton.frame.origin.x, blockingButton.frame.origin.y, 0, blockingButton.frame.height)
No, 0 can cause problems.
Try this:
blockingButton.frame = CGRectMake(blockingButton.frame.origin.x, blockingButton.frame.origin.y, self.view.frame.size.width, blockingButton.frame.height)

How To Arrange a Desain Gameobject or UI to become Scrollable using Scroll Rect ? Unity C#

Please help me..
How to arrange gameobject or UI to become like the screenshot and make it scrollable using scroll rect ?
The UI must be arrange like screenshot.
There is a border yellow contain the UI and it must be scroollable.
and then there is a cyan border contain 5 Slot item or more and scrollable too. it can be generate automatically or manual.
And then there is a magenta border contain 3 button UI. Button 1, button 2, and button 3. Each button have different size.
Why it must be scrollable ? Because The Cyan border Contain and the Magenta border contain can be more than one. So if it not scrollable then the object wouldn't enough to show in the yellow border box.
I have try to make it for 1 day and i can't finish it.
Please help me how to finish it and how to make it step by step.
if you have any question just comment it.
Thanks A lot
I found the answer myself.
That is how it work.
Create Gameobject Name Panelprocess
In the Panelprocess add component : image, mask and scroll rect
Create child Gameobject Panelproceess Name ListProcess
In the ListProcess add component : Grid Layout Group and contain size fitter
at Grid Layout Group component set the value like below :
cell size : x ( 285 ) y ( 65 )
constraint : fixed column count
constraint count : 1
at Contain size fitter set the value like below :
horizontal fit : preffered size
vertical fit : preffered size
Create child Gameobject ListProcess Name Item1 (UI Image), Button1 (UI Image), Item2 (UI Image), Button2 (UI Image)
Create child Gameobject Item1 Name Slot1 (UI Image), Slot2 (UI Image), Slot3 (UI Image), Slot4 (UI Image), Slot5 (UI Image)
Note : Arrange the position and size of slot according to the screenshot
Do step 4 for Item2 too
Create child Gameobject BUtton1 Name Btn1, Btn2, Btn3
Note : Arrange the position and size of each btn1, btn2, btn3 accroding to
the screenshot.
Do step 5 for Button2 too
Back to gameobject Panelprocess
at Panelprocess component :
Scroll Rect (set the setting like below) :
content : (Drag the ListProcess gameobject to content)
Horizontal : unchecked
vertical : checked
MOvement Type : Elastic
Now Play it.
The Grid Layout Group now contain and object with a different size and scrollable.
Done