天天看点

iOS学习笔记之-UIImageView

    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

    //设置透明度

    [imageView setAlpha:0.5];

    //这个设置图像尺寸不对的时候会都显示在上面,但是图像会变形,UIViewContentModeScaleAspectFit这个设置图像会保持比例不变全部显示,但是会有一部分空白还有一种方法,填充这个imageview但是只有一部分显示出来

    imageView.contentMode = UIViewContentModeScaleToFill;

    UIImage*image1 = [UIImage imageNamed:@"img.jpg"];

    [imageView setImage:image1];

    [self.view addSubview:imageView];

iOS学习笔记之-UIImageView

继续阅读