首页 > 代码库 > 常用片段

常用片段

-(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];

}