1 // 标签UILable -显示文字 2 // 1.创建标签 3 UILabel *lable = [[UILabel alloc] init]; 4 // 2.设置标签的坐标和大小 5 [lable setFrame:CGRectMake(0,20, 375, 50)]; 6 // 3.标签内容 7 lable.text = @""; 8 // 设置字体 9 lable.font = [UIFont systemFontOfSize:20]; 10 // 设置字体颜色 11 lable.textColor = [UIColor blackColor]; 12 // 设置内容换行 13 lable.numberOfLines = 0; 14 //设置圆角 15 lable.layer.cornerRadius = 10; 16 lable.layer.masksToBounds = NO; 17 // 设置标签内容居中 18 lable.textAlignment = NSTextAlignmentCenter; 19 // 设置标签背景 20 lable.backgroundColor = [UIColor blackColor]; 21 // 加载图片 22 UIImageView *tempView = [[UIImageView alloc] init]; 23 [tempView setFrame:CGRectMake(255, 0, 120, 50)]; 24 tempView.image = [UIImage imageNamed:@"1.png"]; 25 // 4.在当前视图之上加载子视图 26 [self.view addSubview:lable]; 27 [lable addSubview:tempView];
时间: 2024-10-24 03:30:31