您好,登錄后才能下訂單哦!
IOS學(xué)習(xí)筆記(十)之UIImageView圖片視圖的基本概念和使用方法
Author:hmjiangqq
Email:jiangqqlmj@163.com
UIImageView:
作用:專門用于顯示圖片
首先看下官方的解說:
An p_w_picpath view object provides a view-based container for displaying either a single p_w_picpath or for animating a series of p_w_picpaths. For animating the p_w_picpaths, the UIImageView
class provides controls to set the duration and frequency of the animation. You can also start and stop the animation freely.
When a UIImageView
object displays one of its p_w_picpaths, the actual behavior is based on the properties of the p_w_picpath and the view. If either of the p_w_picpath’s leftCapWidth
ortopCapHeight
properties are non-zero, then the p_w_picpath is stretched according to the values in those properties. Otherwise, the p_w_picpath is scaled, sized to fit, or positioned in the p_w_picpath view according to the contentMode
property of the view. It is recommended (but not required) that you use p_w_picpaths that are all the same size. If the p_w_picpaths are different sizes, each will be adjusted to fit separately based on that mode.
All p_w_picpaths associated with a UIImageView
object should use the same scale
. If your application uses p_w_picpaths with different scales, they may render incorrectly.
實例代碼:
//創(chuàng)建圖片視圖 //創(chuàng)建圖片視圖 UIImageView *p_w_picpathview=[[UIImageView alloc]initWithFrame:CGRectMake(140, 100, 45, 45)]; //設(shè)置高亮 p_w_picpathview.highlighted=YES; //設(shè)置圖片 p_w_picpathview.p_w_picpath=[UIImage p_w_picpathNamed:@"notification_icon"]; //設(shè)置高亮圖片 p_w_picpathview.highlightedImage=[UIImage p_w_picpathNamed:@"notification_icon"]; [self.window addSubview:p_w_picpathview];
- (id)initWithImage:(UIImage *)p_w_picpath; //初始化一張圖片 - (id)initWithImage:(UIImage *)p_w_picpath highlightedImage:(UIImage *)highlightedImage NS_AVAILABLE_IOS(3_0); //初始化 加入一張高亮圖片與本身圖片 //默認圖片 @property(nonatomic,retain) UIImage *p_w_picpath; // 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 //設(shè)置為YES 用戶才可以進行點擊 //設(shè)置為YES 圖片高亮顯示 @property(nonatomic,getter=isHighlighted) BOOL highlighted NS_AVAILABLE_IOS(3_0); // default is NO
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。