1

I use this code for view nib to stackview

for index in 0..<4 {
    let view = CategoryClass.createMyClassView()
    view.myLabel.text = "Hello World!"
    self.stackView.addArrangedSubview(view)
}

And I get below image :

enter image description here

But I want to add subview by category.xib height ( 40px per view ) not fill.

And set in center of parent

Like below :

enter image description here

Screenshot:

enter image description here

RajeshKumar R
  • 15,445
  • 2
  • 38
  • 70
salari mameri
  • 228
  • 5
  • 13

2 Answers2

0

you need to delete the top and bottom constraints of the stackView. Or you can delete any one and make the other constraint in greater than or equal to form This will solve your problem

sanjaykmwt
  • 586
  • 3
  • 19
0
Please add Four label in Xib and after put in stackView and give spacing like 5, 10, 20 whatever you like 

Please check screenshot and let me know if u have any problem related stackview i will help you

enter image description here

Hardik Bar
  • 1,660
  • 18
  • 27