xcode 6.1
File-New-Project..
iOs-Application-Simple View Application
代码:
- (void)viewDidLoad {
[super viewDidLoad]; UILabel *labelLoginname = [[UILabel alloc] initWithFrame:CGRectMake(,,,)];
//[labelLoginname setNumberOfLines:0];
NSString *s = @"账号:";
UIFont *font = [UIFont fontWithName:@"Arial" size:];
CGSize size = CGSizeMake(,); NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:]};
CGSize labelsize = [s boundingRectWithSize:size options: NSStringDrawingUsesFontLeading attributes:attribute context:nil].size; labelLoginname.frame = CGRectMake(80.0, 80.0, labelsize.width, labelsize.height);
labelLoginname.backgroundColor = [UIColor whiteColor];
labelLoginname.textColor = [UIColor blackColor];
labelLoginname.text = s;
labelLoginname.font = font; [self.view addSubview:labelLoginname];
}