iOS label换行 自适应

时间:2023-02-01 09:25:04

       //自动折行设置

        addressDetailLab.lineBreakMode = NSLineBreakByWordWrapping;

        addressDetailLab.numberOfLines = 0;

//自适应

//        CGRect rect = [addressDetailLab.text boundingRectWithSize:CGSizeMake(self.view.frame.size.width, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil];

//       p.size = rect.size;