gpt4 book ai didi

ios - 以编程方式创建的 UILabel 未出现在 IOS 7 Storyboard中

转载 作者:行者123 更新时间:2023-11-29 13:03:04 35 4
gpt4 key购买 nike

基本上,我的简单问题是以编程方式创建的 UILabel 没有出现在 IOS 7 模拟器中,但它可以在 IOS 6 模拟器上运行,我正在使用 Storyboard

我的代码是:

 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); text = 'Power issues - Power Surv...'; clipsToBounds = YES; userInteractionEnabled = NO;层 = CALayer: 0x8db5f30

在 IOS 6 模拟器中

In IOS 6 Simulator

在 IOS 7 模拟器中

In IOS 7 Simulator

最佳答案

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

关于ios - 以编程方式创建的 UILabel 未出现在 IOS 7 Storyboard中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19331597/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com