简体   繁体   中英

Constraints Buttons on LayerView AutoLayout

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

The hierarchy is as following:

在此处输入图片说明

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:

在此处输入图片说明

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

This was the result:

在此处输入图片说明

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

尝试将图层和按钮都放在父UIView ,然后让图层填充该视图,并使按钮在其中垂直居中。

  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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM