UI02_Label

AppDelegate.m
#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

1.需要加入dealloc方法.
- (void)dealloc
{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

2.初始化一个window.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[_window release];

3.在window上添加一个label1.
UILabel *label1 = [UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 200);
label1.backgroundColor = [UIColor yellowColor];
[self.window addSubview:label1];
[label1 release];

4.设置文本内容.
label1.text = @"Messi";

5.设置文本内容的颜色.
label1.textColor = [UIColor blueColor];

6.设置文本的对其方式.
label1.textAlignment = NSTextAlignmentCenter;

7.设置字体大小.
label1.font = [UIFont systemFontOfSize:18];

8.设置行数,默认是一行.如果设置当前的最大行数为零,说明让系统自动寻找适应的行数(两种方法).
label1.numberOfLines = 0;
label1.numberOfLines = NSIntegerMax;

9.设置text的自适应区,要想它能自适应,必须先设置文本内容,再设置行数和自适应.
[label1 sizeToFit];

10.设置断行模式.
label1.lineBreakMode = NSLineBreakByTruncatingMiddle;

11.设置阴影颜色.
label1.shadowColor = [UIColor blackColor];

12.设置阴影大小.
label1.shadowOffset = CGSizeMake(2,1);

13.设置边框.
label1.layer.borderWidth = 1;

14.设置圆角.
label1.layer.cornerRadius = 15;

15.设置内容都在圆角内.
label1.layer.masksToBounds = YES;

16.给框矩形框架重新赋值.
label1.frame = CGRectMake(100, 100, 200, 200);

17.以中心为原点,移动响应位置.如果中心的坐标长度(x,y)正好为边长的1/2,即(x/2,y/2),那么该图形在框架的顶点位置.
括号中的x,y为卫衣长度.
label1.center = CGPointMake(100+x,100+y);

return YES;
}

@end
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值