ios - Alignment in horizontal stack view of label and switch
问题描述
I'm trying to use a horizontal stack view inside of a vertical stack view to create a series of labels and switches for settings. I want the switches to line up vertically but their position changes based on the length of text in the label when have fill proportionally selected. Other choices either throw the switch all the way to the right margin or Fill Equally doesn't leave enough space for a longer label and too much white space to the right of the button.
Thanks
解决方案
UIStackView 正在根据 UIView 安排其子视图intrinsicContentSize
- (CGSize)intrinsicContentSize {
return CGSizeMake(width, height);
}
不要忘记,您应该避免在运行时更改此大小。
推荐阅读
- p5.js - 如何在 StackOverflow 问题中包含可运行的 p5.js 草图?
- php - WooCommerce 上的购物车总重量和运费重新计算
- javascript - Axios 是在客户端处理响应体到 responseType 的转换,还是由服务器处理?
- php - 上传列表中多个项目的文件 laravel
- java - 查看在 Docker 容器内运行的 Java 进程中 CPU 消耗最高的线程
- java - 如何在非容器托管 JPA(Spring Boot 和 Websphere)中使用来自 JDNI 数据源的凭据
- python - Apache Airflow Broken DAG cryptography.utils.InterfaceNotImplemented:
- jestjs - TypeError: (0 , _storeGenerator.storeGenerator) 不是函数
- ios - 尝试呈现已经呈现的内容 - Stripe SwiftUI
- dataframe - 将 HTML 表格放入变量中