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的方法都可以使用
  • 相关阅读:
    ERP渠道管理添加验证和查询(二十二)
    SqlServer导入Excel数据
    WebApi帮助类
    SqlServer 递归查询树
    SqlServer查看表、存储过程、耗时查询、当前进程、开销较大的语句
    Excel上传找到错误数据类型
    索引Hint提示(INDEX Hint)
    SqlServer批量Sql一个表的数据导入到另一个数据
    SqlServer 游标
    JAVA运算符
  • 原文地址:https://www.cnblogs.com/PSSSCode/p/5268686.html
Copyright © 2011-2022 走看看