IOS开发(17)之UIImageView控件
1 前言
显示给用户图片视图,其视图大小控制比较麻烦
2 代码实例
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];//不改变图片的长宽比例
myImageView = [[UIImageView alloc] initWithFrame:self.view.frame];//使图片适应整个视图窗
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];//不改变图片的长宽比例
myImageView = [[UIImageView alloc] initWithFrame:self.view.frame];//使图片适应整个视图窗
myImageView.image = macBook;
myImageView.center = self.view.center;
[self.view addSubview:myImageView];
}
保持原有的比例结果:
充满屏幕运行结果:
补充:移动开发 , IOS ,