UI_UILabel(标签)

UILabel


"AppDelegate.m"


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

    self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];

    // Override point for customization after application launch.

    self.window.backgroundColor = [UIColorwhiteColor];

    [self.windowmakeKeyAndVisible];



    //创建label

   UILabel *newlabel = [[UILabelalloc] initWithFrame:CGRectMake(100, 100, 100, 80)];//window的位置

    

    //设置背景颜色

    newlabel.backgroundColor = [UIColorblueColor];

 

    //添加文本

   newlabel.text= @"用户名";

    

    //设置边框

   newlabel.layer.borderWidth= 0.5;//边框粗细

    

    //设置圆角

   newlabel.layer.cornerRadius= 10;

    

    //隐藏多余的部分

   newlabel.layer.masksToBounds =YES;

    

    //设置文本的对齐方式

    newlabel.textAlignment =NSTextAlignmentCenter;

    

//    newlabel.textColor = [UIColor purpleColor];

//    newlabel.numberOfLines = 3; //行数

    //label自己去根据文字的多少来适应对应的宽度

   [newlabel sizeToFit];

    //设置一个断行模式

    

    newlabel.lineBreakMode =NSLineBreakByTruncatingMiddle;

    

    //设置文字大小

    newlabel.font = [UIFontsystemFontOfSize:20];

    

    //设置阴影的颜色

    newlabel.shadowColor = [UIColoryellowColor];

    

    //设置阴影的偏移量

//    newlabel.shadowOffset = CGSizeMake(10, 10);

    

    [self.windowaddSubview:newlabel];//一定要先把Label先添加到window,Subview是一个数组,会使newlabel的引用计数+1

    

   [newlabel release];


  //第一个参数:NSTimerInterval时间间隔,设置每次执行的时间

    //第二个参数:设置动作的执行人,一般是self

    //第三个参数:设置执行的方法

    //第五个参数:是否重复

    [NSTimer scheduledTimerWithTimeInterval:3 target:selfselector:@selector(test)userInfo:nilrepeats:YES];


    [_window release];

    return YES;

}


- (void)test

{

    NSLog(@"我是测试计时器");

}



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值