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的方法都可以使用
  • 相关阅读:
    sqlserver2005"此数据库没有有效所有者,因此无法安装数据库关系图支持对象"的解决方法
    重复表的复制操作
    重复表中连级下拉框采用数据源时,子级下拉框列表数据无法持久的问题
    SQL server2005连接与进程
    重复表操作
    XPath语法
    Request.ServerVariables 参数大全
    50个Sql语句
    Inside C++ new/delete and new[]/delete[]
    颜色空间
  • 原文地址:https://www.cnblogs.com/PSSSCode/p/5268686.html
Copyright © 2011-2022 走看看