IOS之UILabel的常见属性及用法
2014-12-11 15:38
232 查看
UILabel *label1
= [[UILabel alloc]initWithFrame:CGRectMake(50.0, 20.0, 200.0, 50.0)];//声明时必须指定长宽
label1.text = @"标签显示的文字";
label1.font =
[UIFont boldSystemFontOfSize:20];//设置粗体
正常的是 SystemFontOfSize
label1.textColor = [[UIColoralloc]initWithRed:173/255.0green:225/255.0blue:255/255.0alpha:1];//设置颜色,现成的颜色也很多,注意255.0
label1.textAlignment = UITextAlignmentRight; //设置文字位置
label1.adjustsFontSizeToFitWidth = YES;//设置字体大小适应label宽度
//self.jobNumber.minimumScaleFactor = 8.0;
self.jobNumber.minimumFontSize = 8.0;//设置最小显示字体,字过多时会自适应
4000
label5.numberOfLines = 2;//设置label的行数
label.backgroundColor =
[UIColorclearColor];//去掉背景
其他:
label.transform = CGAffineTransformMakeRotation(0.2);//设置label的旋转角度
label7.userInteractionEnabled = YES; //设置是否能与用户进行交互
label3.enabled = NO;//设置label中的文字是否可变,默认值是YES
label3.lineBreakMode = UILineBreakModeMiddleTruncation;//截去中间 //设置文字过长时的显示格式
//
UILineBreakModeWordWrap = 0,
//
UILineBreakModeCharacterWrap,
//
UILineBreakModeClip,//截去多余部分
//
UILineBreakModeHeadTruncation,//截去头部
//
UILineBreakModeTailTruncation,//截去尾部
//
UILineBreakModeMiddleTruncation,//截去中间
经典特效:
//文字凹陷效果
UILabel *label1
= [[UILabelalloc] initWithFrame:CGRectMake(10,10, 300, 100)];
label1.text =@"文字凹陷效果";
label1.shadowColor = [UIColorcolorWithRed:0.855green:0.863blue:0.882alpha:1.0];
label1.textColor = [UIColorcolorWithRed:0.298green:0.337blue:0.424alpha:1.0];
label1.backgroundColor =
[UIColorcyanColor];
[self.viewaddSubview:label1];
//文字阴影效果
UILabel * label
= [[UILabelalloc] initWithFrame:CGRectMake(10,100, 300, 100)];
label.text =@"文字阴影效果";
label.textColor = [UIColorcolorWithRed:0.4green:0.6blue:0.1alpha:1.0];
label.textAlignment =UITextAlignmentCenter;
label.font = [UIFontfontWithName:[[UIFontfamilyNames] objectAtIndex:2]size:35];
label.adjustsFontSizeToFitWidth =YES;
label.numberOfLines =0;
label.tag =0;
label.backgroundColor =
[UIColorcyanColor];
label.shadowColor =
[UIColoryellowColor];
label.shadowOffset =CGSizeMake(3,3);
[self.viewaddSubview:label];
//label中文字跑马灯效果
UILabel *label3
= [[UILabelalloc] initWithFrame:CGRectMake(10,200, 300, 100)];
label3.text =@"噜啦啦噜啦啦噜啦噜啦噜,噜啦噜啦噜啦噜啦噜啦噜~~~";
[self.viewaddSubview:label3];
CGRect frame =
label3.frame;
frame.origin.x =
-180;
label3.frame =
frame;
[UIViewbeginAnimations:@"testAnimation"context:NULL];
[UIViewsetAnimationDuration:8.8f];
[UIViewsetAnimationCurve:UIViewAnimationCurveLinear];
[UIViewsetAnimationDelegate:self];
[UIViewsetAnimationRepeatAutoreverses:NO];
[UIViewsetAnimationRepeatCount:999999];
frame = label3.frame;
frame.origin.x =350;
label3.frame =
frame;
[UIViewcommitAnimations];
= [[UILabel alloc]initWithFrame:CGRectMake(50.0, 20.0, 200.0, 50.0)];//声明时必须指定长宽
label1.text = @"标签显示的文字";
label1.font =
[UIFont boldSystemFontOfSize:20];//设置粗体
正常的是 SystemFontOfSize
label1.textColor = [[UIColoralloc]initWithRed:173/255.0green:225/255.0blue:255/255.0alpha:1];//设置颜色,现成的颜色也很多,注意255.0
label1.textAlignment = UITextAlignmentRight; //设置文字位置
label1.adjustsFontSizeToFitWidth = YES;//设置字体大小适应label宽度
//self.jobNumber.minimumScaleFactor = 8.0;
self.jobNumber.minimumFontSize = 8.0;//设置最小显示字体,字过多时会自适应
4000
label5.numberOfLines = 2;//设置label的行数
label.backgroundColor =
[UIColorclearColor];//去掉背景
其他:
label.transform = CGAffineTransformMakeRotation(0.2);//设置label的旋转角度
label7.userInteractionEnabled = YES; //设置是否能与用户进行交互
label3.enabled = NO;//设置label中的文字是否可变,默认值是YES
label3.lineBreakMode = UILineBreakModeMiddleTruncation;//截去中间 //设置文字过长时的显示格式
//
UILineBreakModeWordWrap = 0,
//
UILineBreakModeCharacterWrap,
//
UILineBreakModeClip,//截去多余部分
//
UILineBreakModeHeadTruncation,//截去头部
//
UILineBreakModeTailTruncation,//截去尾部
//
UILineBreakModeMiddleTruncation,//截去中间
经典特效:
//文字凹陷效果
UILabel *label1
= [[UILabelalloc] initWithFrame:CGRectMake(10,10, 300, 100)];
label1.text =@"文字凹陷效果";
label1.shadowColor = [UIColorcolorWithRed:0.855green:0.863blue:0.882alpha:1.0];
label1.textColor = [UIColorcolorWithRed:0.298green:0.337blue:0.424alpha:1.0];
label1.backgroundColor =
[UIColorcyanColor];
[self.viewaddSubview:label1];
//文字阴影效果
UILabel * label
= [[UILabelalloc] initWithFrame:CGRectMake(10,100, 300, 100)];
label.text =@"文字阴影效果";
label.textColor = [UIColorcolorWithRed:0.4green:0.6blue:0.1alpha:1.0];
label.textAlignment =UITextAlignmentCenter;
label.font = [UIFontfontWithName:[[UIFontfamilyNames] objectAtIndex:2]size:35];
label.adjustsFontSizeToFitWidth =YES;
label.numberOfLines =0;
label.tag =0;
label.backgroundColor =
[UIColorcyanColor];
label.shadowColor =
[UIColoryellowColor];
label.shadowOffset =CGSizeMake(3,3);
[self.viewaddSubview:label];
//label中文字跑马灯效果
UILabel *label3
= [[UILabelalloc] initWithFrame:CGRectMake(10,200, 300, 100)];
label3.text =@"噜啦啦噜啦啦噜啦噜啦噜,噜啦噜啦噜啦噜啦噜啦噜~~~";
[self.viewaddSubview:label3];
CGRect frame =
label3.frame;
frame.origin.x =
-180;
label3.frame =
frame;
[UIViewbeginAnimations:@"testAnimation"context:NULL];
[UIViewsetAnimationDuration:8.8f];
[UIViewsetAnimationCurve:UIViewAnimationCurveLinear];
[UIViewsetAnimationDelegate:self];
[UIViewsetAnimationRepeatAutoreverses:NO];
[UIViewsetAnimationRepeatCount:999999];
frame = label3.frame;
frame.origin.x =350;
label3.frame =
frame;
[UIViewcommitAnimations];
相关文章推荐
- iphone开发:UILabel的一些属性和常见用法
- IOS控件学习:UILabel常用属性与用法
- IOS中UILabel常见属性及UILabel自适应高度和自动换行
- 【iOS开发】---- ALAsset,ALAssetsLibrary,ALAssetsgroup常见属性及用法
- iOS自学-UILabel常见属性
- IOS控件学习:UILabel常用属性与用法
- IOS控件学习:UILabel常用属性与用法
- 【iOS开发】---- ALAsset,ALAssetsLibrary,ALAssetsgroup常见属性及用法
- iOS - UILabel属性设置和常见使用方法
- IOS控件学习:UILabel常用属性与用法
- IOS控件学习:UILabel常用属性与用法
- IOS学习:UILabel常见用法
- IOS控件学习:UILabel常用属性与用法
- 给iOS开发新手送点福利,简述UILabel的属性和用法
- 【iOS开发】---- ALAsset,ALAssetsLibrary,ALAssetsgroup常见属性及用法
- 给iOS开发新手送点福利,简述UIActivityIndicatorView的属性和用法
- 给iOS开发新手送点福利,简述UIView的属性和用法
- 给iOS开发新手送点福利,简述UITextField的属性和用法
- 给iOS开发新手送点福利,简述UIPageControl的属性和用法
- 给iOS开发新手送点福利,简述UISegment的属性和用法