在水平堆栈视图中居中对齐开关 [英] Center aligning a switch in Horizontal Stack View

查看:36
本文介绍了在水平堆栈视图中居中对齐开关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我对 iOS 开发完全陌生.

Note: I'm completely new to iOS development.

在故事板中,我有一个垂直堆栈视图,里面有一个水平堆栈视图.

In storyboard, I've got a Vertical Stack View with a Horizontal Stack View inside.

在水平堆栈视图中,我有一个标签和一个开关.我将两个堆栈视图的分布更改为等量填充".

In the Horizontal Stack View, I've got a label and a switch. I changed the Distribution of both stack views to "Fill Equally".

目前,这是视图的样子:

Currently, this is what the view looks like:

标签在水平和垂直方向上都完美对齐,但开关位置错误.我还希望开关像标签一样对齐,以便它出现在标签的右侧和同一垂直水平上.

The label is aligned perfectly both horizontally and vertically, but the switch is in the wrong position. I also want the switch to be aligned like the label, so that it appears on the right of the label and on the same vertical level.

我尝试了故事板的各种选项,但似乎没有任何效果.

I've tried various options with storyboard but nothing seems to work.

推荐答案

  1. 将水平 UIStackView 的对齐方式设置为居中.
  2. 将开关嵌入垂直的 UIStackView(在水平的 UIStackView 内).
  3. 将新 UIStackView 的对齐方式设置为居中.

这篇关于在水平堆栈视图中居中对齐开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆