JVS
JVS

Reputation: 2682

Constraints Buttons on LayerView AutoLayout

I am trying to successfully align 2 UIButton laying on TOP of a layerView.

The hierarchy is as following:

enter image description here

The Buttons lay just on top of the layerView (Just a UIView which is black and has a certain alpha). Now I want the buttons to align within this "container".

Like this:

enter image description here

I was setting the constraints to the left and top + to the right and top. also kept aspect ratio.

This was the result:

enter image description here

So it is just the buttons making problems. Anyone knows another way of solving this?

Upvotes: 0

Views: 42

Answers (2)

MSU_Bulldog
MSU_Bulldog

Reputation: 3519

  1. Embed the buttons inside a UIView
  2. Set the UIView to have fixed width and height
  3. Set UIView to horizontally align to Center.
  4. since the "Layer View" has a dynamic height, set the UIView's bottom space to "Layer View"

Upvotes: 2

Wyatt
Wyatt

Reputation: 309

Try putting both the layer and the buttons inside of a parent UIView, then have your layer fill up that view and the buttons centered vertically inside it.

Upvotes: 2

Related Questions