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);
    //
    //    }

  • 相关阅读:

    windows+php+redis的安装
    redis配置
    vim常用快捷键
    php数组的操作技巧
    python3与mysql数据库连接方式
    linux下删除文件夹,修改文件夹下所有文件的权限命令
    Linux下 “.tar.gz”格式的解压与压缩
    Linux解压tar.gz文件时提示gzip:stdin:not in gzip format 错误
    Ubuntu 18.04中安装docker,再在docker中安装mysql,及遇见问题
  • 原文地址:https://www.cnblogs.com/qiqibo/p/2827877.html
Copyright © 2011-2022 走看看