1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| #import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (void)viewDidLoad { [super viewDidLoad]; [self createSubViews]; }
-(void)createSubViews{
UILabel *redLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 100)]; redLabel.backgroundColor = [UIColor redColor]; redLabel.text = @"红色"; [self.view addSubview:redLabel]; UILabel *greenLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 50, 100, 100)]; greenLabel.backgroundColor = [UIColor greenColor]; greenLabel.text = @"绿色"; [self.view addSubview:greenLabel]; UILabel *blueLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 80, 100, 100)]; blueLabel.backgroundColor = [UIColor blueColor]; blueLabel.text = @"蓝色"; [self.view addSubview:blueLabel];
NSLog(@"subViews = %@",self.view.subviews);
}
@end
|