[英]Bounds and Frame Size of a UIView
I need some help to set the bounds and frame of a UIView, I change it to a "full screen mode" by changing the bounds to "0.0f, 0.0f, 1920.0f, 1080.0f" , that works, the problem I'm having is when I need to reverse the UIView back to the original bounds and frame size, but I'm having trouble setting this up. 我需要一些帮助来设置UIView的边界和框架,我通过将边界更改为“ 0.0f,0.0f,1920.0f,1080.0f”将其更改为“全屏模式” ,这有效,我的问题是我需要将UIView还原回原始范围和框架大小时遇到问题,但是在设置时遇到了麻烦。 Can I get some help please? 我可以帮忙吗?
CGRect rect = self.glView.frame;
if (!CGRectEqualToRect(self.view.frame, rect))
{
NSLog(@"Switching to Full Screen now...");
UIView *image = [_avplayController drawableView];
image.frame = CGRectMake(0.0f, 0.0f, 1920.0f, 1080.0f);
self.glView.frame = image.frame;
}
else
{
NSLog(@"Switching to Normal Screen...");
NSLog(@"Old Frame %@", NSStringFromCGRect(self.glView.frame));
NSLog(@"Old Center %@", NSStringFromCGPoint(self.glView.center));
// New Bounds and Frame size
CGRect frame = self.glView.bounds;
frame.size.height = 927.0f;
frame.size.width = 619.0f;
frame.origin.x = 931.0f;
frame.origin.y = 65.0f;
self.glView.bounds = frame;
NSLog(@"New Frame %@", NSStringFromCGRect(self.glView.frame));
NSLog(@"New Center %@", NSStringFromCGPoint(self.glView.center));
}
Try with Frame
instead of Bounds
尝试使用Frame
而不是Bounds
CGRect frame = self.glView.frame;
frame.size.height = 927.0f;
frame.size.width = 619.0f;
frame.origin.x = 931.0f;
frame.origin.y = 65.0f;
self.glView.frame = frame;
The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0). UIView的边界是矩形,表示为相对于其自身坐标系 (0,0)的位置(x,y)和大小(宽度,高度)。
The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within. UIView的框架是矩形,表示为相对于其中包含的超级视图的位置(x,y)和大小(宽度,高度)。
So, frame will help you to adjust your view within superview. 因此,框架将帮助您在超级视图中调整视图。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.