UILabel

AppDelegate.h

#import <UIKit/UIKit.h>
//  按位枚举
typedef NS_ENUM(NSUInteger, NetType) {
    NONet = 1 << 0,
    NetTwoG = 1 << 1,
    NetWlan = 1 << 2,
};

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

AppDelegate.m

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (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.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    [_window release];

    //  按照4步, 来创建一个UILabel
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 150, 50)];
    label.backgroundColor = [UIColor yellowColor];
    [self.window addSubview:label];
    [label release];

    //  能显示文本内容
    label.text = @"我是一只伯符鸟fdasgagaglk卡的结论是覅哦啊嘎嘎骄傲阿哥i";

    //  给label加上一个边框, 并且给它加上一个弧度
    label.layer.borderWidth = 1;
    label.layer.cornerRadius = 10;
    //  让label多余的部分隐藏掉
    label.layer.masksToBounds = YES;

    //  修改字体大小
    label.font = [UIFont systemFontOfSize:19];
#if 0
    //  文字颜色
    label.textColor = [UIColor redColor];

    //  对齐方式
    label.textAlignment = NSTextAlignmentCenter ;

//    NSLog(@"%ld, %ld, %ld", NONet, NetTwoG, NetWlan);
#endif

    //  设置行数
    label.numberOfLines = NSIntegerMax;
    //  可以自动适应文本内容
    [label sizeToFit];
#warning 想要它能自己去适应, 必须先设置文本内容, 再设置行数和自适应


    //  阴影颜色和大小
    label.shadowColor = [UIColor blackColor];
//    label.shadowOffset = CGSizeMake(5, 5);

    label.center = CGPointMake(100, 100);




    return YES;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值