Home > Net >  How to get Label to show on top left of a view in stackView?
How to get Label to show on top left of a view in stackView?

Time:11-20

enter image description here

I want the "Reviews" text to show up in the top left of the third view in stackView (view with select button).

I tried to set top anchor of the label to the top-anchor of the view and am having it show up outside of the third view?

CodePudding user response:

Make @IBOutlet of thirdView@IBOutlet weak var thirdView: UIView!

Add reviewsBoxLabel in thirdView

Replace setupBottomLabelConstraints with:

func setupBottomLabelConstraints() {
    thirdView.addSubview(reviewsBoxLabel)
    reviewsBoxLabel.translatesAutoresizingMaskIntoConstraints=fals
    reviewsBoxLabel.topAnchor.constraint(equalTo:thirdView.topAnchor).isActive=true
    reviewsBoxLabel.leftAnchor.constraint(equalTo:thirdView.leftAnchor).isActive=true 
}
  • Related