UIImageView图片视图的基本概念和使用方法
2015-11-18 11:58
911 查看
IOS学习笔记(十)之UIImageView图片视图的基本概念和使用方法(博客地址: http://blog.csdn.net/developer_jiangqq )
Author:hmjiangqq
Email:jiangqqlmj@163.com
UIImageView:
作用:专门用于显示图片
首先看下官方的解说:
An image view object provides a view-based container for displaying either a single image or for animating a series of images. For animating the images, the
When a
All images associated with a
常用属性和方法:
实例代码:
Author:hmjiangqq
Email:jiangqqlmj@163.com
UIImageView:
作用:专门用于显示图片
首先看下官方的解说:
An image view object provides a view-based container for displaying either a single image or for animating a series of images. For animating the images, the
UIImageViewclass provides controls to set the duration and frequency of the animation. You can also start and stop the animation freely.
When a
UIImageViewobject displays one of its images, the actual behavior is based on the properties of the image and the view. If either of the image’s
leftCapWidthor
topCapHeightproperties are non-zero, then the image is stretched according to the values in those properties. Otherwise, the image is scaled, sized to fit, or positioned in the image view according to the
contentModeproperty of the view. It is recommended (but not required) that you use images that are all the same size. If the images are different sizes, each will be adjusted to fit separately based on that mode.
All images associated with a
UIImageViewobject should use the same
scale. If your application uses images with different scales, they may render incorrectly.
常用属性和方法:
实例代码:
//创建图片视图 UIImageView *imageview=[[UIImageView alloc]initWithFrame:CGRectMake(140, 100, 45, 45)]; //设置高亮 imageview.highlighted=YES; //设置图片 imageview.image=[UIImage imageNamed:@"notification_icon"]; //设置高亮图片 imageview.highlightedImage=[UIImage imageNamed:@"notification_icon"]; [self.window addSubview:imageview];
- (id)initWithImage:(UIImage *)image; //初始化一张图片 - (id)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage NS_AVAILABLE_IOS(3_0); //初始化 加入一张高亮图片与本身图片 //默认图片 @property(nonatomic,retain) UIImage *image; // default is nil //高亮图片 @property(nonatomic,retain) UIImage *highlightedImage NS_AVAILABLE_IOS(3_0); // default is nil @property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled; // default is NO //设置为YES 用户才可以进行点击 //设置为YES 图片高亮显示 @property(nonatomic,getter=isHighlighted) BOOL highlighted NS_AVAILABLE_IOS(3_0); // default is NO
相关文章推荐
- 研究 UIActivityViewController
- UI自动化测试框架之Selenium关键字驱动
- UGUI - Text
- Metro UI 菜单(Winform)
- EasyUI中将DateBox的默认值设置成yyyy-mm-dd格式
- IOS开发指南读书笔记6(UIView家族)
- iOS开发——本地通知,本地推送(UILocalNotification)
- ios上 更改 状态栏(UIStatusBar)的颜色,你值得一看、收藏
- android gradle build
- UICollectionView基础
- UVA 题目10128 Queue(DP)
- UITableViewDelete 删除
- UITabView 添加
- Random_QuickSort
- UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout 还有drawRect方法
- 根据源码总结String,StringBuffer,StringBuider差异
- iOS小技巧:用runtime 解决UIButton 重复点击问题
- UIButton篇
- 【HDU5565 BestCoder Round 62 (div1)C】【STL or 二分答案 or 计数排序】Clarke and baton n个人减肥m次求最后异或值
- UItableViewController添加UITouch事件(添加点击事件)