objective c - 'sizeWithFont:constrainedToSize:lineBreakMode:' is deprecated: first deprecated in iOS 7.0 - Use -boundingRectWithSize:options:attributes:context: -
my app old. now, want update latest ios. deployment target 6.0 when change deployment target 6.0 7.1. app throws many warnings. , 1 of them :
'sizewithfont:constrainedtosize:linebreakmode:' deprecated: first deprecated in ios 7.0 - use -boundingrectwithsize:options:attributes:context:
the warning occur in line:
cgsize expectedlength = [str sizewithfont:str.font constrainedtosize:max linebreakmode:str.linebreakmode];
i try code. don't know how add line break mode. please check:
cgsize mysize = [str sizewithattributes:@{nsfontattributename: str.font}];
i checked in stackoverflow. not satisfied checked answers because of linebreakmode.
may missed of answers. tell me stackoverflow link me.
thanks in advance.
thanks of you. of questions solved problem @ last. here code replace old code :
cgsize max = cgsizemake(str.frame.size.width, 500); cgrect expected1 = [str boundingrectwithsize:max options:nsstringdrawinguseslinefragmentorigin attributes:@{nsfontattributename: str.font } context:nil]; cgsize expected = expected1.size; nslog(@"expected %@",nsstringfromcgsize(expected));
Comments
Post a Comment