-(void)creatLabel
{
label = [[UILabelalloc] init];
label.frame=CGRectMake(60, 100, 200, 50);
NSString *text = @"这是一个测试!!!";
label.text = text;
[labelsetNumberOfLines:0];
UIFont *font = [UIFontfontWithName:@"Arial"size:14];
label.font = font;
[self.viewaddSubview:label];
}
-(void)creatBtn
{
UIButton *btn = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];//初始化button,选择button类型
btn.frame = CGRectMake(130, 100, 90, 35);//大小和位置
[btn setTitle:@"ZoomIn"forState:UIControlStateNormal];//正常状况下button显示的标题
[btn addTarget:selfaction:@selector(showSelectmessage) forControlEvents:UIControlEventTouchUpInside];//
[self.view addSubview:btn];
}
1 - (void)createTabBar{ 2 NSArray *array = [NSArray arrayWithObjects:@"登录_09.png",@"登录_10.png",@"登录_12.png",@"登录_13.png",@"登录_14.png", nil]; 3 NSLog(@"array :%d",array.count); 4 5 for (int i = 0; i<array.count; i++) { 6 UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 7 [btn setBackgroundImage:[UIImage imageNamed:[array objectAtIndex:i]] forState:UIControlStateNormal]; 8 [btn setFrame:CGRectMake(i*64,0,64,44)]; 9 btn.tag = i+100; 10 [btn addTarget:self action:@selector(tabBtnClciked:) forControlEvents:UIControlEventTouchUpInside]; 11 if (i==0) { 12 btn.selected = YES; 13 } 14 [self addSubview:btn]; 15 } 16 17 }