iphone--使用控件数组

来源:互联网 发布:mac safari清除缓存 编辑:程序博客网 时间:2024/05/16 12:55

NSMutableArray *path=[[NSMutableArray alloc]initWithObjects:@"06-7",@"06-6",@"06-5",@"06-8",@"06-4",@"06-2",nil];

for(int i=0;i<6;i++)

{

UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(165+i*139+i, 595139120)];

imageView.backgroundColor=[UIColor blueColor];

UIButton *imageBtn=[UIButton buttonWithType:UIButtonTypeCustom];

imageBtn.frame=CGRectMake(165+i*139+i, 595139120);

NSString *pathImg=[[NSBundle mainBundle]pathForResource:[path objectAtIndex:i] ofType:@"png"];

UIImage *img=[[UIImage alloc]initWithContentsOfFile:pathImg];

[imageView setImage:img];

[self addSubview:imageBtn];

[self addSubview:imageView];

[self sendSubviewToBack:imageView];

}

原创粉丝点击