加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – 如何在ios4中以编程方式向UIImage视图添加图像数组?

发布时间:2020-12-14 19:55:53 所属栏目:百科 来源:网络整理
导读:我需要在单个视图中显示图像数组,这些图像在icarousel(时间机器,封面流等等)中具有各种效果.我将使用单一样式,其中必须显示所有图像. 这是我的代码.M文件.. UIImage *img=[[UIImageView alloc]initWithFrame:CGRectMake(30,30,290,400)];NSLog(@"hi");img.im
我需要在单个视图中显示图像数组,这些图像在icarousel(时间机器,封面流等等)中具有各种效果.我将使用单一样式,其中必须显示所有图像.
这是我的代码.M文件..

UIImage *img=[[UIImageView alloc]initWithFrame:CGRectMake(30,30,290,400)];
NSLog(@"hi");

img.image=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],[UIImage imageNamed:@"Cover_1.png"],[UIImage imageNamed:@"Cover_2.png"],[UIImage imageNamed:@"Cover_3.png"],[UIImage imageNamed:@"Cover_4.png"],[UIImage imageNamed:@"Cover_5.png"],[UIImage imageNamed:@"Cover_6.png"],[UIImage imageNamed:@"Cover_7.png"],nil];

但它不起作用……任何人都可以帮助它…

解决方法

更新:根据您最新的编辑,您的问题完全改变了,因此我的答案不适用.

请改为使用animationImages:

UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(30,400)];
img.animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],nil];

从UIImageView documentation;

animationImages

用于动画的UIImage对象数组.

@property(nonatomic,copy) NSArray *animationImages

Discussion The array must contain UIImage objects. You may use the
same image object more than once in the array. Setting this property
to a value other than nil hides the image represented by the image
property. The value of this property is nil by default.

可用性适用于iOS 2.0及更高版本.也可以看看??@property图片??@property contentMode(UIView)宣告成立UIImageView.h

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读