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的方法都可以使用
  • 相关阅读:
    操作系统--进程间同步
    操作系统--进程间通信
    LeetCode-- Unique Binary Search Trees II
    STL源码--序列容器(一)
    操作系统--用户级线程和内核级线程
    非洲孩子
    寻找最大数(三)
    找点
    心急的C小加
    1044 拦截导弹——http://codevs.cn/problem/1044/
  • 原文地址:https://www.cnblogs.com/PSSSCode/p/5268686.html
Copyright © 2011-2022 走看看