在Objective-C中,可以通过以下步骤在单个视图控制器上加载多个UIView:
完整的代码示例:
UIView *firstView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
firstView.backgroundColor = [UIColor redColor];
firstView.layer.borderWidth = 1.0;
firstView.layer.borderColor = [UIColor blackColor].CGColor;
[self.view addSubview:firstView];
UIView *secondView = [[UIView alloc] initWithFrame:CGRectMake(120, 0, 100, 100)];
secondView.backgroundColor = [UIColor blueColor];
secondView.layer.borderWidth = 1.0;
secondView.layer.borderColor = [UIColor blackColor].CGColor;
[self.view addSubview:secondView];
这样,你就在单个视图控制器上成功加载了两个UIView。你可以根据需要设置每个UIView的位置、大小、样式等属性。
领取专属 10元无门槛券
手把手带您无忧上云