标签:
转自:http://www.runoob.com/ios/att-ios-ui-imageview.html
图像视图用于显示单个图像或动画序列的图像。
重要的属性
- (id)initWithImage:(UIImage *)image
- (id)initWithImage:(UIImage *)image highlightedImage:
(UIImage *)highlightedImage
- (void)startAnimating
- (void)stopAnimating
-(void)addImageView{
UIImageView *imgview = [[UIImageView alloc]
initWithFrame:CGRectMake(10, 10, 300, 400)];
[imgview setImage:[UIImage imageNamed:@"AppleUSA1.jpg"]];
[imgview setContentMode:UIViewContentModeScaleAspectFit];
[self.view addSubview:imgview];
}
这种方法解释了如何对imageView 中的图像进行动画处理
-(void)addImageViewWithAnimation{
UIImageView *imgview = [[UIImageView alloc]
initWithFrame:CGRectMake(10, 10, 300, 400)];
// set an animation
imgview.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"AppleUSA1.jpg"],
[UIImage imageNamed:@"AppleUSA2.jpg"], nil];
imgview.animationDuration = 4.0;
imgview.contentMode = UIViewContentModeCenter;
[imgview startAnimating];
[self.view addSubview:imgview];
}
注意: 我们必须添加命名为"AppleUSA1.jpg"和"AppleUSA2.jpg"到我们的项目,可以通过将图像拖到我们导航区域,其中列出了我们的项目文件所做的图像。
在 ViewController.m 中更新 viewDidLoad,如下所示
(void)viewDidLoad
{
[super viewDidLoad];
[self addImageView];
}
标签:
原文地址:http://www.cnblogs.com/feiyu-mdm/p/5568551.html