Ios 以编程方式或使用情节提要在UIView中显示UILabel
我添加了一个Ios 以编程方式或使用情节提要在UIView中显示UILabel,ios,objective-c,Ios,Objective C,我添加了一个ui视图,现在,我想显示一个ui标签。但是,它不会显示。有人能帮我吗 - (IBAction)infoButtonClicked:(id)sender { myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; myView.transform = CGAffineTransformScale(
ui视图
,现在,我想显示一个ui标签
。但是,它不会显示。有人能帮我吗
- (IBAction)infoButtonClicked:(id)sender {
myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
myView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(5, 10, self.view.frame.size.width, 100)];
[myView addSubview:label];
[self.view addSubview: myView];
[UIView animateWithDuration:0.3/1.5 animations:^{
myView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3/2 animations:^{
myView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3/2 animations:^{
myView.transform = CGAffineTransformIdentity;
label.text=@"The title";
}];
}];
}];
//The setup code to detect single touch
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(oneTap:)];
[myView addGestureRecognizer:singleFingerTap];
}
试试这个
UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(5, 10, myView.frame.size.width, 100)];
label.text = @"sample TExt";
label.numberOfLines = 1;
label.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; // or UIBaselineAdjustmentAlignCenters, or UIBaselineAdjustmentNone
label.adjustsFontSizeToFitWidth = YES;
label.adjustsLetterSpacingToFitWidth = YES;
label.minimumScaleFactor = 10.0f/12.0f;
label.clipsToBounds = YES;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blackColor];
label.textAlignment = NSTextAlignmentLeft;
[myView addSubview:label];
您的编码是好的,添加上面的行也和检查oncecheck一次,如果我的答案是好的,我们定制的东西