UI01_UILabel

 /**********************************************************************************/

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    

    

    self.window =[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];

    self.window.backgroundColor =[UIColor whiteColor];

    [self.window makeKeyAndVisible];

    [_window release];


    UIViewController *vc =[[UIViewController alloc]init];

    self.window.rootViewController =vc;

    [vc release];

    

    

    

//    UIView *view1 =[[UIView alloc] initWithFrame:CGRectMake(80, 80, 100, 100)];

//    view1.backgroundColor =[UIColor blackColor];

//    [self.window addSubview:view1];

//    [view1 release];

//    

//    UIView *view2 =[[UIView alloc] initWithFrame:CGRectMake(100, 150, 100, 100)];

//    view2.backgroundColor =[UIColor redColor];

//    [self.window addSubview:view2];

//    [view2 release];

    

    

    //UILabel

    UILabel *label1 =[[UILabel alloc] initWithFrame:CGRectMake(80, 80, 100, 100)];

    label1.backgroundColor =[UIColor yellowColor];

    [self.window addSubview:label1];

    [label1 release];

    /// label添加文本

      label1.text =@"程锦乐,afadf,水电费是sf, 阿斯顿发撒旦,dfgdfg,dfgdfg,dfgdfgd";

    ///设置文本的颜色

    label1.textColor =[UIColor greenColor];

    /// 设置文本的对齐方式

    label1.textAlignment =NSTextAlignmentCenter;

    ///设置文本字体大小

    label1.font =[UIFont systemFontOfSize:15];

    /// 设置行数

    label1.numberOfLines =0;

    [label1 sizeToFit];

    //想通过这两方法进行自适应的话,必须先有文本,后有对行数和sizeToFit的设置

    //它会自动修改尺寸,把高度增加

    NSLog(@"%g",label1.frame.size.height);

    // shadw  增加阴影

    label1.shadowColor = [UIColor  redColor];

    // shadw  扩充阴影

    label1.shadowOffset =CGSizeMake(2, 2);

    //center只能设置位置,而且还是中心点的位置

    //frame都可以进行设置

    label1.center =CGPointMake(0, 0);

    label1.center =CGPointMake(100+label1.frame.size.width / 2 , 100+label1.frame.size.height / 2);

    

    

    

    /// 随机颜色

    [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1];

    

    

    

    return YES;

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值