zoukankan      html  css  js  c++  java
  • 什么是UIImageView

    UIKit框架提供了非常多的UI控件,但并不是每一个都很常用,有些控件可能1年内都用不上,有些控件天天用,比如UIButton、UILabel、UIImageView、UITableView等等


    UIImageView极其常用,功能比较专一:显示图片

        // 1.1 创建UIImageView对象
        UIImageView *imageView = [[UIImageView alloc] init];
        
        // 1.2 设置frame
        imageView.frame = CGRectMake(100, 100, 250, 200);
        
        // 1.3 设置背景
        //    imageView.backgroundColor = [UIColor greenColor];
        
        // 1.4 设置图片 (png不需要后缀)
        imageView.image = [UIImage imageNamed:@"1"];
        
        /**
         
         UIViewContentModeRedraw, // 重新绘制 (核心绘图) drawRact
         
         //带有Scale,标明图片有可能被拉伸或压缩
         UIViewContentModeScaleToFill, // 完全的压缩或拉伸
         
         // Aspect 比例,缩放是带有比例的
         UIViewContentModeScaleAspectFit, // 宽高比不变 Fit 适应
         UIViewContentModeScaleAspectFill, // 宽高比不变 Fill 填充
         
         //不带有Scale,标明图片不可能被拉伸或压缩
         UIViewContentModeCenter,
         UIViewContentModeTop,
         UIViewContentModeBottom,
         UIViewContentModeLeft,
         UIViewContentModeRight,
         UIViewContentModeTopLeft,
         UIViewContentModeTopRight,
         UIViewContentModeBottomLeft,
         UIViewContentModeBottomRight,
         */
        // 1.5 设置图片的内容模式
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        
        // 2.0 加到控制器的view中
        [self.view addSubview:imageView];
        
        // 裁剪多余的部分
        imageView.clipsToBounds = YES;
  • 相关阅读:
    vs2017 离线安装。
    c# begin & end.
    vc++ 下的WaitForSingleObject
    c# 工厂模式 ,委托 ,事件。
    微信分享 andriod studio
    mac osx 10.9 ftp server端口
    win32 调用多媒体函数PlaySound()
    [汇编语言]-第九章 在屏幕中间分别显示绿底红色,白底蓝色字符串"welcome to masm!"
    [汇编语言]-第九章 jcxz,loop指令,转移位移的意义
    补码
  • 原文地址:https://www.cnblogs.com/xufengyuan/p/6036764.html
Copyright © 2011-2022 走看看