简体   繁体   English

集合视图单元格内按钮的填充宽度

[英]Fill width of button inside collection view cell

Is there an easy way of doing this? 有一个简单的方法吗? I'm using storyboard to align a button inside a cell manually (set width/height) trying to get it to fit inside a cell within a collection view. 我正在使用情节提要来手动对齐单元格内部的按钮(设置宽度/高度),以使其适合集合视图中的单元格。 The problem is that while it may fit one version of iphone, example iPhone 6 it doesn't fit on iPhone 5 - different resolutions and all. 问题在于,尽管它可能适合一个版本的iPhone,例如iPhone 6,但不适用于iPhone 5-分辨率和所有分辨率都不同。

Is there a Swift way of forcing the button width to fit inside cell, as in fit the full width of the cell? 是否有一种快速的方法来强制按钮宽度适合单元格内部,就像适合单元格的整个宽度一样?

First, delete the width constraint (if you have one). 首先,删除宽度约束(如果有的话)。 Then pin the button to the edges and set constraints: 然后将按钮固定到边缘并设置约束:

在此处输入图片说明

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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