zoukankan      html  css  js  c++  java
  • UITextView自适应高度解决方法

    if (content) {
            CGSize constraint = CGSizeMake(self.contentWide, CGFLOAT_MAX);
            CGSize size = [content sizeWithFont:contentFont constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
            
            frame = CGRectMake(self.contentX, y, self.contentWide, size.height+16);
            UITextView *textView = [[UITextView alloc] initWithFrame:frame];
            
            textView.text = content;
          
            
            textView.autoresizesSubviews = YES;
            textView.autoresizingMask =(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
            
            textView.backgroundColor = [UIColor clearColor];
            textView.userInteractionEnabled = NO;
        
            
            textView.textColor = contentColor;
            [contentView addSubview:textView];
            [textView release];
            
            y += (textView.contentSize.height);
        }
        
    //    UITextView *textView = [[UITextView alloc] initWithFrame:frame];
    //   
    //    if (content) {
    //        
    //        textView.backgroundColor = [UIColor clearColor];
    //        textView.userInteractionEnabled = NO;
    //        textView.text = content;
    //        [textView setFrame:CGRectMake(self.contentX, y, self.contentWide, textView.contentSize.height)];
    //        CGFloat height = textView.contentSize.height;
    //        [textView setFrame:CGRectMake(self.contentX, y, self.contentWide, height)];
    //        textView.textColor = contentColor;
    //        [contentView addSubview:textView];
    //        [textView release];
    //         y += (textView.frame.size.height + 16);
    //
    //    }

  • 相关阅读:
    begin lydsy 2731
    关于js中this关键字的补充
    js中this关键字测试集锦
    js文件中函数前加分号和感叹号是什么意思?
    好用的wget命令从下载添加环境变量到各参数详解
    一个解析json串并组装echarts的option的函数解析
    oschina代码仓库远程push,pull免密实操总结
    yii 核心类classes.php详解(持续更新中...)
    yii2.0归档安装方法
    配置windows 系统PHP系统环境变量
  • 原文地址:https://www.cnblogs.com/qiqibo/p/2827877.html
Copyright © 2011-2022 走看看