我想您可以简单地使用带有视图的 NSMutableArray。这是我为展示我的想法而制作的一个示例:
- (void)viewDidLoad {
[super viewDidLoad];
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 20, 40)];
[view1 setBackgroundColor:[UIColor blackColor]];
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(150, 100, 20, 40)];
[view2 setBackgroundColor:[UIColor whiteColor]];
UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(200, 100, 20, 40)];
[view3 setBackgroundColor:[UIColor redColor]];
[self.view addSubview:view1];
[self.view addSubview:view2];
[self.view addSubview:view3];
NSMutableArray *views = [NSMutableArray arrayWithObjects:view1, view2, view3, nil];
[self changeViews:views];
}
-(void)changeViews:(NSMutableArray *)viewsArray {
for (UIView *view in viewsArray) {
[view setBackgroundColor:[UIColor blueColor]];//any changes you want to perform
}
}