- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我不知道如何在固定左右边距的情况下调整宽度。
我没有找到任何固定的 led/右边距 API。
最佳答案
在代码中,要使 View 具有固定的左右边距以及灵活的宽度,您可以执行以下操作:
UIView *parentView = self.view; // adjust as needed
CGRect bounds = parentView.bounds; // get bounds of parent view
CGRect subviewFrame = CGRectInset(bounds, 20, 0); // left and right margin of 20
UIView *subview = [[UIView alloc] initWithFrame:subviewFrame];
subview.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[parentView addSubview:subview];
根据需要进行调整以创建您的实际 subview 。调整 subviewFrame
以匹配您想要的边距。
如前所述,这将为您的 subview 提供固定的左右边距,每个 20 点和一个灵活的宽度。设置 autoresizingMask
时,任何未设置为灵活的组件都会自动修复(几乎)。这意味着上边距和高度也是固定的(因为它们未设置)。由于上边距和高度是固定的,因此下边距是隐式灵活的。由于显而易见的原因,不能同时固定所有三个跨越或上升/下降的值。
关于ios - UIView autoresizingMask 用于固定左右边距和灵活宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16049009/
我实现了一个小的 viewDidLoad() 来显示自动调整大小的图片,但它不起作用,请有人帮助我并说出错误是什么这段代码在第 3 行和第 4 行??? imageView = [[UIImageVi
在包含多个 subview 的 View 中,其中一个 subview 应与父 View 的顶部和底部保持固定的非零距离。在这些图像中,该 View 显示为灰色: 根据文档,此 View 应具有 UI
我试图让它与 ViewController View 中的代码一起工作: 但我无法让它工作。 我试过了 -(void)loadView { UIView *contentView = [[[U
我以编程方式在屏幕上放置了一个带有框架(0、100、50、50)的 UIView,并将其 autoresizingMask 设置为 UIViewAutoresizingFlexibleLeftMarg
我在 LeftMenu VC 的 tableView 中使用 autoResizingMask,如果我将表格拖动到间隙,效果很好 - 它可以很好地调整大小,但随后我放开我的 tableView,它会恢
LiveStreamTable=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 768, 960)]; LiveStreamTable.autor
如何在 UIView 子类中使用 NSLayoutConstraints(或 anchor )编写以下代码? func commonInit() { aView
我有一个 View 出现在其父 View 纵向模式的中心,我应该使用什么 autoresizemask 以便它也出现在横向模式的中心。它的大小应该保持不变。我只希望它的原点应该在该点自动移动,以便它出
我想处理 autoresizingmasks,但由于某种原因,我无法显示对话。我的 IB 的尺寸检查器如下所示: 当我点击另一个检查器——属性、连接等时——自动调整掩码对话框/检查器会出现一瞬间(时间
我以编程方式在屏幕上放置了一个 UISegmentedControl(独立的,而不是作为导航栏的一部分),并将其 autoresizingMask 设置为 UIViewAutoresizingFlex
我已设置应用程序以便自动旋转。像 tableviewcontrollers 和 tabbarcontrollers 这样的东西会自动调整它们的大小,而不需要我编写任何代码。但是,当设备转向横向时,我需
第一次在堆栈溢出问题上发帖。 我花了几个小时搜索了许多 Google 搜索,此时,我几乎记住了 UIView 和 UIViewController 类引用文档。无论我做什么,我的应用程序都会忽略我调整
我有一个显示自定义单元格的 View 表格 View 。这些单元格有一个 UIImageView,如果设备处于横向模式,则需要对其进行缩放。 我将tableView的autoresizingMask设
我正在尝试使用该代码创建一个带有左插入分隔符的 View (如 iOS 7 中的表格 View 单元格): UIView *container = [[UIView alloc] initWithFr
我不知道如何在固定左右边距的情况下调整宽度。 我没有找到任何固定的 led/右边距 API。 最佳答案 在代码中,要使 View 具有固定的左右边距以及灵活的宽度,您可以执行以下操作: UIView
我有一个带有多个标签的自定义 uitableviewcell,我希望其中一些标签能够根据内容(文本)自动调整其框架(宽度)的大小。我不知道如何做到这一点。我尝试设置标签的固定框架并在应用 autore
我在我的代码中使用了这样的东西 Btn.autoresizingMask = UIViewAutoresizingFlexibleTopMargin + UIViewAutoresizingFlexi
我的问题很简单。 我目前正在对 UIButton 进行子类化以创建一些自定义动画。但是,当我将 translatesAutoresizingMaskIntoConstraints 设置为 false
我了解到在单 View 应用程序中设置覆盖整个主视图(全宽和全高)的 UITableView 的正确方法是,在 viewDidLoad: table = [[UITableView alloc] in
我正在尝试使用 inputAccessoryView 来处理 iPhone X。我已经像这样向我的 ViewController 添加了一个 View : 自定义 View 我已经定义了一个导出并连接
我是一名优秀的程序员,十分优秀!