Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

ios - Adjusting UIView Height Inside UIStackView Control

I am using a UIStackView in iOS 9 SDK. The height of the stackview is 44 points. I have a UILabel and UIView inside the StackView as shown below:

enter image description here

Now, I want to make the green view much smaller than 44.. much like 20. How can I do that?

Without the UIStackView I am getting breaking constraints:

[GT.BubbleView:0x14536610]   (Names: '|':UITableViewCellContentView:0x14536fd0 )>",
    "<NSLayoutConstraint:0x146b7300 GT.BubbleView:0x14536610.trailing == UITableViewCellContentView:0x14536fd0.trailingMargin>",
    "<NSLayoutConstraint:0x146c4000 'UIView-Encapsulated-Layout-Width' H:[UITableViewCellContentView:0x14536fd0(286)]>")
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. First you need to add UIStackView on the cell enter image description here

  2. Need to add constraints to your UIStackView enter image description here

  3. Adjust your UIStackView enter image description here

  4. Drag&Drop UILabel into your UIStackView enter image description here

  5. Then Drag&Drop UIView into your UIStackView enter image description here

  6. Add green-UIView like subview to pink UIView enter image description here

  7. Now you can add couple constraints to green-UIView enter image description here enter image description here

  8. Now you can run app on simulator or device enter image description here enter image description here

    Notice that I don't added any constraints for UILabel.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...