//
// ViewController.m
// ZSYDemo
//
// Created by 程磊 on 14/11/1.
// Copyright (c) 2014年 程磊. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *str = @"我我我我哦我我啊的 啊坟蛋撒是";
CGSize size = [str sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(250, 320) lineBreakMode:NSLineBreakByCharWrapping];//iOS6
NSLog(@"%f %f",size.width,size.height);
//iOS7
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping;
NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14], NSParagraphStyleAttributeName:paragraphStyle.copy};
CGSize size3 = [str boundingRectWithSize:CGSizeMake(250, 320) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil].size;
// CGSize size2 = [str boundingRectWithSize:CGSizeMake(250, 320) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:NSLineBreakByCharWrapping].size;
NSLog(@"%f %f",size3.width, size3.height);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end