xcode 内容插图不起作用 Storyboard Xcode8
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37838039/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Content inset not working Storyboard Xcode8
提问by Alex Andrews
Recently I have updated Xcode 7.3 to 8. While opening the project the project settings also have been updated for new Xcode.
最近我将 Xcode 7.3 更新为 8。在打开项目时,项目设置也已针对新 Xcode 更新。
Now the insets given for a button image for positioning the image inside button frame is not working as in previous Xcode(7.3) version.
现在,用于在按钮框架内定位图像的按钮图像的插图与以前的 Xcode(7.3) 版本不同。
The image insets are given through storyboard. Image was used here to have large clickable area for button than the button image display area. Is there any other options to get it through storyboard.
图像插入是通过故事板给出的。此处使用图像是为了比按钮图像显示区域具有更大的按钮可点击区域。有没有其他选择可以通过故事板获得它。
回答by maxkonovalov
In Xcode 8 the button content/title/image insets have moved to the Size Inspector tab:
在 Xcode 8 中,按钮内容/标题/图像插入已移至 Size Inspector 选项卡:
Which seems quite logical by the way!
顺便说一句,这似乎很合乎逻辑!
回答by Bryan Norden
I had this same problem and solved it with image insets and the Horizontal/Vertical Alignment controls. My problem was that I had the wrong alignment controls selected. Once I changed it my insets worked properly for what I was trying to accomplish.
我遇到了同样的问题,并使用图像插入和水平/垂直对齐控件解决了它。我的问题是我选择了错误的对齐控件。一旦我改变了它,我的插图就可以正常工作以完成我想要完成的工作。
I created a button with an image and the I wanted to shrink the image down to not fill up the entire button So I set the image to the UIButton image property in storyboard and then set the image insets to my liking
我创建了一个带有图像的按钮,我想缩小图像以不填满整个按钮 所以我将图像设置为故事板中的 UIButton 图像属性,然后根据我的喜好设置图像插入
But it did not center my image with the inset of 5 on each side. The image would look like this and that was not what I wanted
但它并没有将我的图像以每边 5 的插图居中。图像看起来像这样,那不是我想要的
If you change the horizontal/vertical alignment controls I was able to the button image to my desired look I wanted
如果您更改水平/垂直对齐控件,我可以将按钮图像更改为我想要的外观
回答by RAHUL JOSHI
Its weird,but it actually works until you add collectionviewor tableviewin your Viewcontroller. Try setting the inset without having the scrollview or tableview in your view controller
它很奇怪,但它实际上可以工作,直到您在 Viewcontroller 中添加collectionview或tableview。尝试在视图控制器中没有滚动视图或表格视图的情况下设置插图