#import "ViewController.h"app
@interface ViewController ()字體
@property(strong,nonatomic) UILabel *lable;atom
@endip
@implementation ViewControllerit
- (void)viewDidLoad {io
[super viewDidLoad];table
[self.lable setNumberOfLines:0];import
self.lable.text=@"最近一年多,儘管交易數據靚麗,但通過一年操做後,老王發現炒房仍是沒有利潤空間。他終於明白,房價已失去大漲的土壤環境,主要是房源庫存量大,傳統企業生存艱難,年輕人購房慾望減弱,資產配置轉向資本市場,「炒房已經到了末日」[2006年至2011年,溫州市區商品房銷售均價從8045元/平方米一路上漲至34674元/平方米,5年時間漲了3倍左右。老王說,溫州房價每平方米從1萬元漲到2萬元,花了一年多點時間;從2萬元漲到3萬元,只用了一年不到。][2009年,溫州人均GDP僅4604美圓,在浙江省排倒數第三,不到杭州的一半,也只有浙江省人均GDP的71%。]";配置
self.lable.backgroundColor=[UIColor grayColor];im
// 設置段落風格
NSMutableParagraphStyle *par=[[NSMutableParagraphStyle alloc]init];
par.lineHeightMultiple=NSLineBreakByCharWrapping;
// 設置段落字體風格
NSDictionary *dic=@{NSFontAttributeName:self.lable.font,NSParagraphStyleAttributeName:par.copy};
// 計算 lable 的實際大小 返回文本繪製的區域
CGRect rect=[self.lable.text boundingRectWithSize:CGSizeMake(self.view.frame.size.width, self.view.frame.size.height) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
// 設置標籤到屏幕頂端的距離
self.lable.frame=CGRectMake(0, 70, rect.size.width, rect.size.height);
[self.view addSubview:self.lable];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end