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

  • 相关阅读:
    CSS为英文和中文字体分别设置不同的字体
    进程控制之孤儿进程
    求解逻辑问题:谁养鱼
    2019-7-29-win10-uwp-如何使用DataTemplate
    2019-7-29-win10-uwp-如何使用DataTemplate
    2018-8-10-win10-uwp-修改Pivot-Header-颜色
    2018-8-10-win10-uwp-修改Pivot-Header-颜色
    2018-10-17-Sublime-Text-好用的插件
    2018-10-17-Sublime-Text-好用的插件
    2018-11-13-WPF-禁用实时触摸
  • 原文地址:https://www.cnblogs.com/qiqibo/p/2827877.html
Copyright © 2011-2022 走看看