1 Preface
It is difficult to control the size of images displayed to users.
2. code example
ZYViewController. m:
[Plain]
@ Synthesize myImageView;
-(Void) viewDidLoad
{
[Super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImage * macBook = [UIImage imageNamed: @ "Apple.png"];
// MyImageView = [[UIImageView alloc] initWithImage: macBook]; // do not change the aspect ratio of the image.
MyImageView = [[UIImageView alloc] initWithFrame: self. view. frame]; // adapt the image to the entire view window
MyImageView. image = macBook;
MyImageView. center = self. view. center;
[Self. view addSubview: myImageView];
}
@ Synthesize myImageView;
-(Void) viewDidLoad
{
[Super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImage * macBook = [UIImage imageNamed: @ "Apple.png"];
// MyImageView = [[UIImageView alloc] initWithImage: macBook]; // do not change the aspect ratio of the image.
MyImageView = [[UIImageView alloc] initWithFrame: self. view. frame]; // adapt the image to the entire view window
MyImageView. image = macBook;
MyImageView. center = self. view. center;
[Self. view addSubview: myImageView];
}
Result of maintaining the original proportion:
Full Screen running result: