zoukankan      html  css  js  c++  java
  • UIImage的简单用法和实际操作

    png,pdf不需要添加后缀名

    jpg添加后缀名

    存储

    UIImagejpg

    contentMode属性

         这个属性是用来设置图片的显示方式,如居中、居右,是否缩放等,有以下几个常量可供设定:

         

         UIViewContentModeScaleToFill

         UIViewContentModeScaleAspectFit

         UIViewContentModeScaleAspectFill

         UIViewContentModeRedraw

         UIViewContentModeCenter

         UIViewContentModeTop

         UIViewContentModeBottom

         UIViewContentModeLeft

         UIViewContentModeRight

         UIViewContentModeTopLeft

         UIViewContentModeTopRight

         UIViewContentModeBottomLeft

         UIViewContentModeBottomRight

         

    注意以上几个常量,凡是没有带Scale的,当图片尺寸超过 ImageView尺寸时,只有部分显示在ImageView中。

    UIViewContentModeScaleToFill属性会导致图片变形,图片填充满frame(默认)。

    UIViewContentModeScaleAspectFit会保证图片比例不变,而且全部显示在ImageView中,这意味着ImageView会有部分空白。

    UIViewContentModeScaleAspectFill也会证图片比例不变,但是是填充整个ImageView的,可能只有部分图片显示出来。

    例如: imageView.contentMode = UIViewContentModeLeft;

     

    圆切:

    imageView.layer.cornerRadius = 10

    //隐藏圆外的东西

    imageView.layer.masksToBounds = YES;、//隐藏

    imageView.clipsToBounds = YES;//切掉

    //设置边线宽度

    imageView.layer.borderWidth = 4 ;

    //设置边线颜色

    imageView.layer.borderColor = [UIColor blackColor].CGColor;

    //设置阴影颜色

    imageView.layer.shadowColor = [UIColor greenColor].CGColor;

    //设置阴影大小

    imageView.layer.shadowOffset = CGSizeMake(2, 2);

    //设置不透明度

    imageView.layer.shadowOpacity = 1.5;

    继承于uiview的方法都可以使用
  • 相关阅读:
    osg编译日志
    MFC加载大型osg模型
    osg gdal加载tif数据文件
    osg创建灯光
    ubuntu挂载新硬盘
    MFC加载osg模型
    nginx中Geoip_module模块的使用
    centos中释放缓存的方法
    python连接kafka生产者,消费者脚本
    python初始化环境记录
  • 原文地址:https://www.cnblogs.com/PSSSCode/p/5268686.html
Copyright © 2011-2022 走看看