OC过期方法/属性替换汇总

1.sizeWithFont.(iOS7.0废除) - > sizeWithAttributes

  

  (1) CGSize size = CGSizeZero;

        size = [title sizeWithFont:[UIFont systemFontOfSize:15]];  -->

        size  = [title sizeWithAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15]}];

 

   

  (2)CGSize size =[value sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(CGFLOAT_MAX,height) lineBreakMode:NSLineBreakByWordWrapping];   -->

   NSAttributedString *attributedText =[[NSAttributedString alloc] initWithString:value attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:fontSize]}];

       CGRect rect = [attributedText boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, height)

                                               options:NSStringDrawingUsesLineFragmentOrigin

                                               context:nil];

       CGSize size = rect.size;

 

2.label.lineBreakMode = UILineBreakModeWordWrap; (iOS6.0废除)-->

label.lineBreakMode = NSLineBreakByWordWrapping;

 

posted @ 2017-07-31 11:34  刚刚888  阅读(345)  评论(0编辑  收藏  举报