获取多行文本框的大小(搬砖的)

单行

CGSizesize =[self.storeName.text sizeWithAttributes:@{NSFontAttributeName:[UIFontsystemFontOfSize:14]}];

多行

titleLabel.numberOfLines = 0;//多行显示,计算高度

CGSize titleSize = [titleContent boundingRectWithSize:CGSizeMake(kScreen_Width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;


textView

CGRectframe =self.textView.frame;

CGSizeconstraintSize =CGSizeMake(frame.size.width,MAXFLOAT);

CGSizesize = [self.textViewsizeThatFits:constraintSize];

你可能感兴趣的:(获取多行文本框的大小(搬砖的))