UIImageView边界,框架

我知道这里有很多类似的问题,我检查了这个着名的问题,然后把握了界限和框架之间的区别。

现在我有一些与他们有关的问题。 我和他们一起玩,但没有像我预期的那样performance出来。

我不明白的是:

  • 为什么Y的帧起始位置是44.000000,即使我在左上angular设置了UIImageView? 因为边界应该是“UIView的边界是矩形,表示为相对于它自己的坐标系(0,0)的位置(x,y)和大小(宽度,高度)。 ( cocoa:框架和界限有什么区别? )我认为框架也应该从左边angular落开始。

在这里输入图像说明

#import "ViewController.h" @interface ViewController () //@property (weak, nonatomic) IBOutlet UIImageView *image; @property (weak, nonatomic) IBOutlet UIImageView *image2; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //UIImage *imageView = [UIImage imageNamed:@"stanford"]; // self.image.alpha = 1; // self.image.contentMode = 1; // self.image.image = imageView; // [self.image setAlpha:0.1]; // [self.image setContentMode:UIViewContentModeCenter]; // [self.image setImage:imageView]; NSURL *url = [[NSURL alloc] initWithString:@"http://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/Pitbull_2%2C_2012.jpg/472px-Pitbull_2%2C_2012.jpg"]; NSData *data = [NSData dataWithContentsOfURL:url]; UIImage *imageData = [UIImage imageWithData:data]; [self.image2 setBounds:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; [self.image2 setImage:imageData]; NSLog(@"frame.orign.x:%f,frame.origin.y:%f",self.image2.frame.origin.x,self.image2.frame.origin.y); } 

44幻数值实际上来自导航栏:)而状态栏的高度是20点。

如果你想让你的图片覆盖整个屏幕,那么你需要摆脱状态栏,或者让你的状态栏半透明,以便内容可以显示在下面。

如果您没有将状态栏/导航栏设置为半透明状态,则原点0,0将从您现在遇到的栏的正下方开始。

状态栏是使用设置的

 [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent]; 

导航栏,如果你有一个显示可以使用这个设置

 theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent; 

只有这样,您的以下代码才能在整个屏幕上显示您的内容

 [self.image2 setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)] 

这是因为将条设置为半透明将会使其显示为叠加。

44来自导航栏,占据了这么高的高度