在自定义视图上定位图像,需要澄清
我有一个尺寸为 320 x 376 的视图,
在此视图之上,我想放置一个 UIImageView,留下 4 个(不确定这里的测量单位是什么)指向每个尺寸。这(我希望)将在图像周围创建一个框架。
因此,从视图的立场来看,
- 起始 x,y 坐标将为
4 x 4。
- 计算顶视图的宽度,i
320 - 4 - 4 = 312
> - 计算顶视图的高度,我
376 - 4 - 4 = 368
当所述测量到位时,但是我得到
为什么我没有看到底部有 4 点缓冲区?
I have a view sized 320 x 376
On top of this view, i'd like to place a UIImageView leaving 4 (not sure what is the unit of measurements here) points to each size. This (i hope) will create a frame around the image.
So, from the stand point of the view,
- Starting x,y coordinates will be
4 x 4.
- Calculating the width of the top view, i
320 - 4 - 4 = 312
- Calculating the height of the top view, i
376 - 4 - 4 = 368
When said measurements are in place, however i get
Why am i not seeing a 4 points buffer towards the bottom?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用您的参数进行测试,对我来说没问题:
我发现解释为什么会发生这种情况的唯一原因是因为另外 2 个视图(边框视图 + 图像视图)后面的视图比 376 短,所以它隐藏了视图的底部:(
这里是绿色的视图)
好的
太短
Tested with your params, it's ok for me :
The only reason that I found to explain why this happens is because the view that is behind the 2 others (border view + image view) is shorter than 376, so it hides the bottom of your views :
(here, it's the green one)
OK
Too short