UILabel 详细说明
UILabel属性及应用
UILabel *label1 =[ [UILabel alloc] initWithFrame:CGRectMake(20,40,280,80)]; //创建label
label1.backgroundColor = [ UIColor grayColor];
label1.tag = 91; //设置tag
label1.text = @"helloworld"; //设置标签文本
label1.font = [ UIFont fontWithName:@"Arial" size:30]; //文本字体和文本大小
label1.textAlignment = UITextAlignmentCenter; //对齐方式
typedef enum{
UITextAlignmentLeft = 0, //左对齐
UITextAlignmentCenter, //居中对齐
UITextAlignmentRight, //右对齐
}UITextAlignment;
label1.textColor = [ UIColor blueColor]; //设置文本颜色
label1.lineBreakMode = UILineBreakModeTailFruncation; //超出label1边界文字的截取方式
typedef enum{ www.zzzyk.com
UILineBreakModeWordWrap = 0, //以空格为边界,保留整个单词
UILineBreakModeCharacterWrap, //保留整个字符
UILineBreakModeClip, //到边界为止
UILineBreakModeHeadTruncation, //省略开始,以... ... 代替
UILineBreakModeTailTruncation, //省略结尾,以... ...代替
UILineBreakModeMiddleTruncation,//省略中间,以... ...代替,多行时作用于最后一行
}
label1.adjustsFontSizeToFitWidth = YES; //文本文字自适应大小(如果文本font要偏小时)
label1.baselineAdjustment = UIBaselineAdjustmentAlignCenters; //控制文本基线位置,一行文本有效
typedef enum{
UIBaselineAdjustmentAlignBaselines = 0, //默认值文本上端位于label1中线对齐
UIBaselineAdjustmentAligncenters, //文本中线位于label1中线对齐
UIBaselineAdjustmentNone, //文本最低端与label1中线对齐
}UIBaselineAdjustment;
label1.numberOfLine = 2; //文本最多行数,为0时没有最大行数限制
label1.minimumFontSize = 10.0; //最小字体行数为1时有效 默认0.0
label1.highlighted = YES; //设置文本高亮
label1.enabled = YES; //文本是否可变
label1.backgroundColor = [ UIColor clearColor]; //去掉背景色
label1.shadowColor = [ UIColor grayColor]; //文本阴影颜色
label1.shadowOffset = CGRectMake(1.0,1.0); //阴影大小
label1.userInteractionEnabled = YES; //能否与用户交互
[self.view addSubView:label1];
[label1 release];
补充:综合编程 , 其他综合 ,