UILabel

UILabel

code

文本中間對齊

    UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 150, 35)];
    myLabel.text = @"This is a Label";
    myLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview: myLabel];
    [myLabel release];

圓角邊框

    UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 150, 35)];
    myLabel.text = @"This is a Label";
    myLabel.layer.cornerRadius = 5;
    myLabel.layer.borderWidth = 1;
    [self.view addSubview: myLabel];
    [myLabel release];

設置字體大小

myLabel.font = [UIFont systemFontOfSize: 17];

property

文本顏色 textColor

陰影平移 shadowOffset

陰影 shadowColor

字體 font

對齊方式 textAlignment

最大行數 numberOfLines

邊框寬度 layer.borderWidth

邊框弧度 layer.cornerRadius

隱藏邊框多餘部分(圓形標籤) layer.masksToBounds = YES

Method

sizeToFit 讓標籤大小適合文字 不要放在text屬性設置之前

發佈了26 篇原創文章 · 獲贊 0 · 訪問量 5237
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章