码迷,mamicode.com
首页 > 移动开发 > 详细

iOS中的UILabel

时间:2015-08-27 22:54:55      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    
    
    UIView *containterView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    containterView.backgroundColor = [UIColor whiteColor];
    [self.window addSubview:containterView];
    [containterView release];
    /*
     UILabel(标签):UIView 的子类,在UIView的基础上扩充了显示文字的功能
     UILabel的使用步骤:
     1.创建对象
     2.配置属性
     3.添加到父视图
     4.释放所有权
     */
    UILabel *alabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 100)];
    
    alabel.backgroundColor = [UIColor blueColor];
    
    //设置显示的参数
    alabel.text = @"我是蓝欧lanouhn 快快快快快快快快快!";
    alabel.textColor = [UIColor redColor];
    //设置字体大小
    alabel.font = [UIFont systemFontOfSize:24];
    alabel.font = [UIFont fontWithName:@"AvenirNextCondensed-HeavyItalic" size:26];
    
    //换行
    //截取方式
    //alabel.lineBreakMode = NSLineBreakByCharWrapping;
    //按单词换行
    alabel.lineBreakMode = NSLineBreakByWordWrapping;
    alabel.numberOfLines = 0;
    [containterView addSubview:alabel];
    //设置阴影的颜色
    alabel.shadowColor = [UIColor yellowColor];
    //设置label的阴影偏移量
    alabel.shadowOffset = CGSizeMake(1, 3);
    
    //设置文本对齐方式
    [alabel release];
    alabel.textAlignment = NSTextAlignmentCenter;
    

    
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

 

iOS中的UILabel

标签:

原文地址:http://www.cnblogs.com/wohaoxue/p/4764808.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!