简体   繁体   English

我如何全屏显示图像

[英]how do I show an image full screen

How do I show a UIImageview fullscreen (programmatically) so that it takes the whole view in Objective-C? 如何全屏显示UIImageview(以编程方式),以便在Objective-C中获取整个视图? I tried doing: 我试着做:

   [self.centerImage setFrame: CGRectMake(self.centerImage.frame.origin.x, self.centerImage.frame.origin.y, img.size.width, img.size.height)];

but the origin.x just does not give me a full screen representation 但是origin.x并没有给我全屏显示

thanks 谢谢

The "whole view" will vary in size depending what device you're on. “整体视图”的大小将根据您所使用的设备而有所不同。 So the first step is to use auto layout and pin the four sides of the image view to the four sides of its superview. 因此,第一步是使用自动布局,然后将图像视图的四个侧面固定到其超级视图的四个侧面。 Now it exactly covers the "whole view". 现在,它正好涵盖了“整体视图”。 You will then have to play with the content mode, but that's a different matter. 然后,您将不得不使用内容模式,但这是另一回事。

如果要以全屏显示图像,则将视图框架分配给图像视图,如下所示

self.centerImage.frame = self.view.frame

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

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