将UIImageView添加为子视图
我试图创建一个具有某些图像约束的动画UIImageView。将UIImageView添加为子视图
我希望UIImageView的动画大小为141x262,而不是整个屏幕。目前我有这个代码:
CJ = [[UIImageView alloc] initWithFrame:self.view.frame];
CJ.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"CJ_1.png"],
[UIImage imageNamed:@"CJ_2.png"],
[UIImage imageNamed:@"CJ_3.png"], nil];
CJ.animationDuration = 1;
CJ.animationRepeatCount = 0;
[CJ startAnimating];
[self.view addSubview:CJ];
任何和所有的帮助将不胜感激!
如果你想视图是一个不同的大小,设置其框架是尺寸:
CJ = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 141, 162)];
如果你的图片是大,你可能还需要设置你的视图contentMode。例如:
CJ.contentMode = UIViewContentModeScaleAspectFit;
不,它仍占用整个屏幕。 – user1521367 2012-07-12 16:23:27
我已经添加了另一个建议 – 2012-07-12 16:28:24
这并不是说图像很大,Xcode是拉伸图像(我只希望它是它的大小)。 Xcode:http://cl.ly/I2eT我想要什么:http://cl.ly/I2XX – user1521367 2012-07-12 16:30:46
您是否还在使用界面构建器? – sridvijay 2012-07-12 16:20:52
是的,我正在使用界面生成器。 – user1521367 2012-07-12 16:29:14