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的方法都可以使用
  • 相关阅读:
    线程、同步
    异常、线程
    Map
    List、Set
    Collection、泛型
    Object类、常用API
    h5-上传图片预览
    js 获取get参数
    《转》完美解决微信video视频隐藏控件和内联播放问题
    写入文件(覆盖文件的内容)
  • 原文地址:https://www.cnblogs.com/PSSSCode/p/5268686.html
Copyright © 2011-2022 走看看