编程创建的UILabel在IOS 7分镜未出现

问题描述 投票:1回答:2

基本上我的简单的问题是程序创建的UILabel在IOS 7模拟器没有出现,但它在IOS 6模拟器工作,我用故事板

我的代码是:

 UILabel *lbl_top = [[UILabel alloc]initWithFrame:CGRectMake(10, 100, 100, 100)];
    lbl_top.text = text;
    lbl_top.font = customFont;
    lbl_top.numberOfLines = 1;
    lbl_top.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; 
    lbl_top.adjustsFontSizeToFitWidth = YES;
    lbl_top.adjustsLetterSpacingToFitWidth = YES;
    lbl_top.minimumScaleFactor = 10.0f/12.0f;
    lbl_top.clipsToBounds = YES;
    lbl_top.backgroundColor = [UIColor clearColor];
    lbl_top.textColor = [UIColor blackColor];
    lbl_top.textAlignment = NSTextAlignmentLeft;
    lbl_top.hidden = FALSE;
    lbl_top.alpha = 1.0;
    [self.view addSubview:lbl_top];

控制台打印:

打印lbl_top的描述:

的UILabel:0x8dae430;帧=(10 100; 100 100);文本=“电源问题 - 电源监测网......”; clipsToBounds = YES; userInteractionEnabled = NO;层= CALayer的:0x8db5f30

在IOS 6模拟器

在IOS 7模拟器

ios objective-c ios6 storyboard ios7
2个回答
1
投票
try this code 

UILabel *lbl_top = [[UILabel alloc]initWithFrame:CGRectMake(10, 100, 100, 100)];
lbl_top.text = @"agssudass ";
lbl_top.font = [UIFont systemFontOfSize:15.0];
lbl_top.numberOfLines = 1;
lbl_top.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;
lbl_top.adjustsFontSizeToFitWidth = YES;
lbl_top.adjustsLetterSpacingToFitWidth = YES;
lbl_top.minimumScaleFactor = 10.0f/12.0f;
lbl_top.clipsToBounds = YES;
lbl_top.backgroundColor = [UIColor blackColor];
lbl_top.textColor = [UIColor whiteColor];
lbl_top.textAlignment = NSTextAlignmentLeft;
lbl_top.hidden = FALSE;
lbl_top.alpha = 1.0;
[self.view addSubview:lbl_top];

变化

lbl_top.text = @"agssudass ";
lbl_top.backgroundColor = [UIColor blackColor];
lbl_top.font = [UIFont systemFontOfSize:15.0]; 
lbl_top.textColor = [UIColor whiteColor];

0
投票

我想你没有设置该标签中的文本proparly。设置喜欢的文本

lolabel.text = @"Welcome";

一旦检查您的字体也可能是您的字体不支持iOS 7。一旦更改字体为默认字体和检查出来。

© www.soinside.com 2019 - 2024. All rights reserved.