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

  • 相关阅读:
    网络通信之 字节序转换原理与网络字节序、大端和小端模式
    [C/C++]大小端字节序转换程序
    面向对象和面向过程的区别
    编译libjpeg
    地形系统lod
    c/c++ 代码中使用sse指令集加速
    个人作品- 蘑菇大战
    个人作品- 几何战争
    Obj格式模型 读取
    各大引擎矩阵的矩阵存储方式 ----行矩阵 or 列矩阵
  • 原文地址:https://www.cnblogs.com/qiqibo/p/2827877.html
Copyright © 2011-2022 走看看