IOS#UI之UILabel
本来已经写了很多,就因为切换页面就没有了,以后切之前得注意了 mac电脑的伤不起
UI里面有很多控件比如UIView UIControl UILabel UIButton UIScrollView UIWindow UIWebView UITabBarUITableViewUITableViewCellUIToolbarUITextFieldUITextView UIImageViewUIPageControlUIPickerViewUIProgressViewUIAlertViewUISearchBarUISegmentedControlUISearchBarUISliderUISwitchUICollectionView 6.0UICollectionReusableView等
控制器有
UIPageViewControllerUIPopoverControllerUIImagePickerControllerUINavigationControllerUISplitViewControllerUICollectionViewControllerUITableViewController
开在写了,废话少说,
先将UILabel UIView和UIResponder后面在写,
UILabel的
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 280, 100)];
aLabel.backgroundColor = [UIColor greenColor];
aLabel.text = @"这是我在2013年的程序,今天也是我要写ios、mac和操作系统相关的技术博文,我的bolg分别是(1)http://www.cnblogs.com/leevaboo(2)http://blog.csdn.net/leevaboo,(3)http://3660064.blog.51cto.com";
aLabel.textAlignment = NSTextAlignmentCenter;//左中右对其的模式 default is left
aLabel.textColor = [UIColor blueColor];//文本颜色default is blackColor
aLabel.font = [UIFont systemFontOfSize:20];//字体的大小default is 17
aLabel.shadowColor = [UIColor redColor];//阴影default is nil
aLabel.shadowOffset = CGSizeMake(0, 1);//阴影的位置,按照xy轴的坐标位置来,default is (0 -1)表示x = 0 ,y = -1 表示在阴影在正下方 x轴左到右是负到正,y上到下是负到正
aLabel.lineBreakMode = NSLineBreakByTruncatingTail;//文本超过label的边界的文本截取方式default is NSLineBreakByTruncatingTail
aLabel.highlightedTextColor = [UIColor purpleColor];//设置文本的高亮颜色 default is nil
aLabel.highlighted = NO;//打开高亮default is NO
aLabel.userInteractionEnabled = NO;//是否交互.default is NP
aLabel.adjustsFontSizeToFitWidth = NO;//根据宽调整字体的大小 但是numberOfLines = 1;default is NO
aLabel.numberOfLines = 0;
float height = [aLabel.text sizeWithFont:aLabel.font constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:NSLineBreakByWordWrapping].height;//根据字符串的长度和字号的大小和Label的宽度自动计算label的高度
aLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;//设置label的基准线
aLabel.frame = CGRectMake(20, 100, 280, height);
[self.view addSubview:aLabel];
[aLabel release];
// Do any additional setup after loading the view.
}
本来已经写了很多,就因为切换页面就没有了,以后切之前得注意了 mac电脑的伤不起
UI里面有很多控件比如UIView UIControl UILabel UIButton UIScrollView UIWindow UIWebView UITabBarUITableViewUITableViewCellUIToolbarUITextFieldUITextView UIImageViewUIPageControlUIPickerViewUIProgressViewUIAlertViewUISearchBarUISegmentedControlUISearchBarUISliderUISwitchUICollectionView 6.0UICollectionReusableView等
控制器有
UIPageViewControllerUIPopoverControllerUIImagePickerControllerUINavigationControllerUISplitViewControllerUICollectionViewControllerUITableViewController
开在写了,废话少说,
先将UILabel UIView和UIResponder后面在写,
UILabel的
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 280, 100)];
aLabel.backgroundColor = [UIColor greenColor];
aLabel.text = @"这是我在2013年的程序,今天也是我要写ios、mac和操作系统相关的技术博文,我的bolg分别是(1)http://www.cnblogs.com/leevaboo(2)http://blog.csdn.net/leevaboo,(3)http://3660064.blog.51cto.com";
aLabel.textAlignment = NSTextAlignmentCenter;//左中右对其的模式 default is left
aLabel.textColor = [UIColor blueColor];//文本颜色default is blackColor
aLabel.font = [UIFont systemFontOfSize:20];//字体的大小default is 17
aLabel.shadowColor = [UIColor redColor];//阴影default is nil
aLabel.shadowOffset = CGSizeMake(0, 1);//阴影的位置,按照xy轴的坐标位置来,default is (0 -1)表示x = 0 ,y = -1 表示在阴影在正下方 x轴左到右是负到正,y上到下是负到正
aLabel.lineBreakMode = NSLineBreakByTruncatingTail;//文本超过label的边界的文本截取方式default is NSLineBreakByTruncatingTail
aLabel.highlightedTextColor = [UIColor purpleColor];//设置文本的高亮颜色 default is nil
aLabel.highlighted = NO;//打开高亮default is NO
aLabel.userInteractionEnabled = NO;//是否交互.default is NP
aLabel.adjustsFontSizeToFitWidth = NO;//根据宽调整字体的大小 但是numberOfLines = 1;default is NO
aLabel.numberOfLines = 0;
float height = [aLabel.text sizeWithFont:aLabel.font constrainedToSize:CGSizeMake(280, 100000) lineBreakMode:NSLineBreakByWordWrapping].height;//根据字符串的长度和字号的大小和Label的宽度自动计算label的高度
aLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;//设置label的基准线
aLabel.frame = CGRectMake(20, 100, 280, height);
[self.view addSubview:aLabel];
[aLabel release];
// Do any additional setup after loading the view.
}
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。