在实现网络异步存储中,突然发现对控件UIImageView有点生疏了,在这里复习一下。

UIImageView,顾名思义是用来放置image的。

1.初始化UIImageView
 

  UIImageView *imgShadow = [[UIImageView alloc] initWithFrame:CGRectMake(50, 150, 150, 80)];

[imgShadow setImage:[UIImage imageNamed:@"9.jpg"]];

  [self.view addSubview:imgShadow];

2.为UIImageView添加效果

// 设置边框颜色

[imgShadow.layer setBorderColor: [[UIColor whiteColor] CGColor]];

// 设置边框宽度

[imgShadow.layer setBorderWidth: 1.0];

// 设置投影偏移量,CGSizeMake(x轴方向, y轴方向)

[[imgShadow layer] setShadowOffset:CGSizeMake(1, 1)];

// 设置投影颜色

[[imgShadow layer] setShadowColor:[UIColor redColor].CGColor];

// 设置投影半径

[[imgShadow layer] setShadowRadius:3];

// 设置透明度

[[imgShadow layer] setShadowOpacity:1];

  //
当设置为YES时,超过边界的将被遮盖(隐藏),经常与cornerRadius,属性使用。这样,圆角外的区域将被遮盖

   [imgShadow.layer setMasksToBounds:YES];

// 设置圆角

imgShadow.layer.cornerRadius = 10;

3.更改位置

更改一个UIImageView的位置,可以

3.1 直接修改其frame属性

3.2 修改其center属性:

imageView.center = CGPointMake(CGFloat x, CGFloat y);

center属性指的就是这个ImageView的中间点。

3.3 使用transform属性

imageView.transform = CGAffineTransformMakeTranslation(CGFloat dx, CGFloat dy);

其中dx与dy表示想要往x或者y方向移动多少,而不是移动到多少。

4、旋转图像

  imageView.transform = CGAffineTransformMakeRotation(CGFloat angle);

    要注意它是按照顺时针方向旋转的,而且旋转中心是原始ImageView的中心,也就是center属性表示的位置。

   这个方法的参数angle的单位是弧度,而不是我们最常用的度数,所以可以写一个宏定义:

  #define degreesToRadians(x) (M_PI*(x)/180.0)

小编写的不完全,若有遗漏,请及时联系!!!

UI控件(ios)---UIImageView的更多相关文章

  1. UI控件之UIImageView

    UIImageView:图像视图,用于在应用程序中显示图片 UIImage:是将图片文件转换为程序中的图片对象 UIImageView是UIImage的载体 方法一:用此方法创建图片对象,会将图片ca ...

  2. UI控件(UIImageView)

    @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; image1_ = [UIImage imageNa ...

  3. iOS基础UI控件介绍-Swift版

    iOS基础UI控件总结 iOS基础控件包括以下几类: 1.继承自NSObject:(暂列为控件) UIColor //颜色 UIImage //图像 2.继承自UIView: 只能相应手势UIGest ...

  4. IOS学习资源收集--开发UI控件相关

    收集的一些本人了解过的iOS开发UI控件相关的代码资源(本文持续补充更新) 内容大纲: 1.本人在github上也上传了我分装好的一些可重复利用的UI控件 2.计时相关的自定义UILabel控件 正文 ...

  5. iOS 中UI控件的各种对齐方式总结

    1.textAligment : 文字的水平方向的对齐方式 取值 NSTextAlignmentLeft      = 0,    // 左对齐 NSTextAlignmentCenter    = ...

  6. ios 中的UI控件学习总结(1)

    UIKit框架提供了非常多功能强大又易用的UI控件 下面列举一些在开发中可能用得上的UI控件 UIButton 按钮 UILabel 文本标签 UITextField 文本输入框 UIImageVie ...

  7. 【IOS 开发】基本 UI 控件详解 (UIDatePicker | UIPickerView | UIStepper | UIWebView | UIToolBar )

    转载注明出处 : http://blog.csdn.net/shulianghan/article/details/50348982 一. 日期选择器 (UIDatePicker) UIDatePic ...

  8. iOS 使用UI控件的外观协议UIAppearance进行设置默认UI控件样式

    在iOS开发中,经常会对UINavigationBar的样式进行全局样式.采用的设置方式有两种: 第一种,采用方式如下: [UINavigationBar appearance] 这种是对一类对象的默 ...

  9. iOS基本UI控件总结

    包括以下几类: //继承自NSObject:(暂列为控件) UIColor *_color;    //颜色 UIImage *_image;    //图像 //继承自UIView:只能相应手势UI ...

  10. iOS UI控件继承关系图

    闲来无事,把UI控件的继承关系图整理下来,供自己和大家使用.

随机推荐

  1. insserv: Script <name> is broken: incomplete LSB comment.

    insserv: Script <name> is broken: incomplete LSB comment. insserv: missing `Required-Start:' e ...

  2. np.clip截取函数

    np.clip截取函数 觉得有用的话,欢迎一起讨论相互学习~Follow Me 将范围外的数强制转化为范围内的数 def clip(a, a_min, a_max, out=None): 将数组a中的 ...

  3. bzoj千题计划174:bzoj1800: [Ahoi2009]fly 飞行棋

    http://www.lydsy.com/JudgeOnline/problem.php?id=1800 圆上两条直径构成矩形的对角线 #include<cstdio> using nam ...

  4. day63_SpringMVC学习笔记_01

    1.JAVAEE体系结构 JAVAEE体系结构图如下所示: 2.什么是springmvc? 什么是mvc? Model1 Model2 SpringMVC是什么? SpringMVC是一个web层mv ...

  5. Convert Expression to Reverse Polish Notation

    Given an expression string array, return the Reverse Polish notation of this expression. (remove the ...

  6. Linux系统基本命令

    要区分大小写 uname 显示版本信息(同win2K的 ver) dir 显示当前目录文件 ls -al 显示包括隐藏文件(同win2K的 dir) pwd 查询当前所在的目录位置 cd .. 回到上 ...

  7. appium-Could not obtain screenshot: [object Object]

    原因 App页面已经被禁止截屏,禁用用户截屏的代码如下: getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); setConten ...

  8. testng运行失败,继续执行

    1.重写断言类 public class Verify { public static StringBuffer verificationErrors= new StringBuffer();; pu ...

  9. css-position属性实例2

    position 1) fixed 固定在页面某个位置 2) absolute 也可以固定在某个位置,一般结合relative使用 注: 1)fixed和absoulue区别,假如一个div固定在右下 ...

  10. 几个比较实用的CSS

    1.filter:chroma(color:#FFFFFF);    让指定的背景色透明,例: <table cellspacing = "0" cellpadding = ...