UILabel的使用
2015-06-03 11:21
288 查看
UILabel *label=[[UILabelalloc]init];
label.font = [UIFontitalicSystemFontOfSize:25];
//设置字体
//[UIFont systemFontOfSize:25]
可以设置字体大小
//[UIFont boldSystemFontOfSize:25]
可以设置字体大小并且字体加粗
//[UIFont italicSystemFontOfSize:25]
可以设置斜体并且设置字体大小,但是斜体不支持中文
// //查看ios7中得所有可用字体
NSArray *array=[UIFontfamilyNames];
//快速枚举遍历数组,查看系统中所有字体的名称
for(NSString *strNamein array)
{
NSLog(@"%@",strName);
}
label.font=[UIFontfontWithName:@"Bodoni
72 Smallcaps"size:25];
//设置阴影颜色
label.shadowColor=[UIColorgreenColor];
//设置阴影的偏移量
label.shadowOffset=CGSizeMake(10,5);
//设置折行模式
label.lineBreakMode =NSLineBreakByTruncatingHead;
根据Label的内容来算出Label的高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath
*)indexPath
{
NSDictionary *dict = [_resultArrayobjectAtIndex:indexPath.row];
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_0
CGSize size = [[dictobjectForKey:@"content"] boundingRectWithSize:CGSizeMake(180.0f,20000.0f) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFontsystemFontOfSize:14]} context:nil].size;
#else
UIFont *font = [UIFontsystemFontOfSize:14];
CGSize
size = [[dictobjectForKey:@"content”]sizeWithFont:font constrainedToSize:CGSizeMake(180.0f,20000.0f)
lineBreakMode:NSLineBreakByWordWrapping];
#endif
return size.height+44;
}
label.font = [UIFontitalicSystemFontOfSize:25];
//设置字体
//[UIFont systemFontOfSize:25]
可以设置字体大小
//[UIFont boldSystemFontOfSize:25]
可以设置字体大小并且字体加粗
//[UIFont italicSystemFontOfSize:25]
可以设置斜体并且设置字体大小,但是斜体不支持中文
// //查看ios7中得所有可用字体
NSArray *array=[UIFontfamilyNames];
//快速枚举遍历数组,查看系统中所有字体的名称
for(NSString *strNamein array)
{
NSLog(@"%@",strName);
}
label.font=[UIFontfontWithName:@"Bodoni
72 Smallcaps"size:25];
//设置阴影颜色
label.shadowColor=[UIColorgreenColor];
//设置阴影的偏移量
label.shadowOffset=CGSizeMake(10,5);
//设置折行模式
label.lineBreakMode =NSLineBreakByTruncatingHead;
根据Label的内容来算出Label的高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath
*)indexPath
{
NSDictionary *dict = [_resultArrayobjectAtIndex:indexPath.row];
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_0
CGSize size = [[dictobjectForKey:@"content"] boundingRectWithSize:CGSizeMake(180.0f,20000.0f) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFontsystemFontOfSize:14]} context:nil].size;
#else
UIFont *font = [UIFontsystemFontOfSize:14];
CGSize
size = [[dictobjectForKey:@"content”]sizeWithFont:font constrainedToSize:CGSizeMake(180.0f,20000.0f)
lineBreakMode:NSLineBreakByWordWrapping];
#endif
return size.height+44;
}
相关文章推荐
- UIScrollView控件介绍
- STL系列之五 priority_queue 优先级队列
- BLE/Bluetooth Low Energy
- Druid数据源配置入门(超详细)
- Druid数据源配置入门(超详细)
- ling join 报错The specified LINQ expression contains references to queries that are associated with different cont
- IOS UIButton的一些设置代码
- STL系列之三 queue 单向队列
- iOS学习(4)——UITextField
- STL系列之一 deque双向队列
- 021_02UI之自定义主题和样式
- 对于dequeueReusableCellWithIdentifier:的个人理解
- iOS 根据字体调整UILabel的大小
- ios7 uitableview内容视图下移 20px bug
- hadoop mapreduce模式读取sequence文件
- 交互设计分享(一)
- hadoop单机模式读取sequence文件
- easyui 右键绑定事件
- hadoop读取 Sequence格式的文件的代码
- requirejs的配置