#import "ViewController.h"
@interface ViewController ()
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self ninePic];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)ninePic
{
NSMutableArray *_imageArr = [NSMutableArray arrayWithCapacity:10];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
CGRect rect = CGRectMake(18.75+j*118.75, 200+i*118.75, 100, 100);
UIImageView *imageView = [[UIImageView alloc]initWithFrame:rect];
imageView.backgroundColor = [UIColor purpleColor];
[self.view addSubview:imageView];
[_imageArr addObject:imageView];
}
}
NSLog(@"%@", _imageArr);
UIImageView *iv = (UIImageView *)_imageArr[4];
iv.backgroundColor = [UIColor redColor];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
来源:oschina
链接:https://my.oschina.net/u/2483781/blog/544492