您的位置:首页 > 移动开发 > Objective-C

Objective-c for 循环 九宫格

2015-12-15 00:00 543 查看
#import "ViewController.h"

@interface ViewController ()

@end

@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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: