如何改变UILabel的大小 [英] how to change the size of UILabel

查看:113
本文介绍了如何改变UILabel的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以编程方式编码的UILabel。我想按下按钮时改变标签的大小。如何更改标签的大小?这是我的代码

I have a UILabel coded programmatically. I want to change the size of the label when i pressed a button. how to change the size of that label? this is my code

 UILabel *theLabel11 = [[UILabel alloc] initWithFrame:CGRectMake(0,0,100,30)];  
[theLabel11 setText:@"US"];
[theLabel11 setTextAlignment:UITextAlignmentCenter];
[theLabel11 setFont: [UIFont fontWithName:@"Arial" size:13.0f]];
[theLabel11 setBackgroundColor:[UIColor orangeColor]];
[theLabel11 setTextColor:[UIColor blackColor]];
[scroll1 addSubview:theLabel11];    


推荐答案

你应该将你的标签声明为类属性,所以它可以从其他方法访问

You should declare your label as class property, so it can be accessed from other methods

要更改字体大小,请使用

To change the font size use

[theLabel11 setFont: [UIFont fontWithName:@"Arial" size:13.0f]];

要更改标签的框架尺寸,我们

To change the frame size of the label us

theLabel11.frame = CGRectMake(x, y, width, height);

这篇关于如何改变UILabel的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆