Objective-c for 循環 九宮格


#import "ViewController.h"spa


@interface ViewController ().net


@end 3d


@implementation ViewControllerorm


- (void)viewDidLoad {ci

    [super viewDidLoad];get

    

    [self ninePic];it

    // Do any additional setup after loading the view, typically from a nib.io

}table


-(void)ninePicimport

{

    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

相關文章
相關標籤/搜索