前段时间已经把 Object-C 过了一遍了,现在要开始 IOS 开发的实战学习了。因为之前是做 .Net 开发的,所以,转过来的时间,还是有好多不适应和困惑的,特别是 C# -> Object-C 和 VS -> XCode,其中更有很多思想和操作都是不同的,没办法,只有一步步来了。
本文首发于,博客园,请搜索:博客园 - 寻自己,查看原版文章
本文首发地址:IOS控件Label(UILabel) - www.cnblogs.com/xunziji/archive/2012/09/20/2695474.html
本文首发于,博客园,请搜索:博客园 - 寻自己,查看原版文章
本文首发地址:IOS控件Label(UILabel) - www.cnblogs.com/xunziji/archive/2012/09/20/2695474.html
2. font : text 的 font-family 和 font-size,可读写,值类型为 UIFont,默认值为system font at a size of 17
3. textColor : 文本的颜色,可读写的属性,值类型为 UIColor,默认值为 Black
6. enabled : 控件是否可用,感觉对于 Label 来说比较鸡肋,为 false 后,只是把颜色变灰而已,如果想要隐藏UILabel(Label),请用hidden 属性
//隐藏Label(UILabel):lblUserName [lblUserName setHidden:true];
本文首发于,博客园,请搜索:博客园 - 寻自己,查看原版文章
本文首发地址:IOS控件Label(UILabel) - www.cnblogs.com/xunziji/archive/2012/09/20/2695474.html
本文首发于,博客园,请搜索:博客园 - 寻自己,查看原版文章
本文首发地址:IOS控件Label(UILabel) - www.cnblogs.com/xunziji/archive/2012/09/20/2695474.html
NSString *txt = @"The UILabel class implements a read-only text view. You can use this class to draw one or multiple lines of static text, such as those you might use to identify other parts of your user interface. \n The base UILabel class provides support for both simple and complex styling of the label text. You can also control over aspects of appearance, such as whether the label uses a shadow or draws with a highlight. \n If needed, you can customize the appearance of your text further by subclassing.The default content mode of the UILabel class is UIViewContentModeRedraw. \n This mode causes the view to redraw its contents every time its bounding rectangle changes. \n You can change this mode by modifying the inherited contentMode property of the class.New label objects are configured to disregard user events by default. \n If you want to handle events in a custom subclass of UILabel, you must explicitly change the value of the userInteractionEnabled property to YES after initializing the object."; learnLabel.text =txt; UIFont *font = [UIFont systemFontOfSize:16]; learnLabel.font =font; /*Test 1 设置 UIlabel 高度*/learnLabel.numberOfLines =0; CGSize txtSize =[txt sizeWithFont:font constrainedToSize:CGSizeMake(400, 200) lineBreakMode:UILineBreakModeCharacterWrap]; learnLabel.frame =CGRectMake(learnLabel.frame.origin.x, learnLabel.frame.origin.y, txtSize.width, txtSize.height); /*Test 3 测试 Highlightcolor & highlight learnLabel.highlighted = true; learnLabel.textColor = [UIColor greenColor]; learnLabel.highlightedTextColor = [UIColor blueColor]; */ /*Test 4 测试 shadowColor & shadowOffset*/learnLabel.font =[UIFont systemFontOfSize:34]; learnLabel.shadowColor =[UIColor greenColor]; learnLabel.shadowOffset = CGSizeMake(0.0,0.000001); learnLabel.backgroundColor =[UIColor grayColor]; /*Test 2 设置自动换行、大小自适应 learnLabel.lineBreakMode = UILineBreakModeWordWrap; learnLabel.numberOfLines = 0; CGSize size = [learnLabel sizeThatFits:CGSizeMake(500, 0)]; CGRect rect = learnLabel.frame; rect.size =size; learnLabel.frame = rect; */