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

  • 相关阅读:
    【BZOJ3995】[SDOI2015]道路修建 线段树区间合并
    [Noip2016]天天爱跑步 LCA+DFS
    【BZOJ2870】最长道路tree 点分治+树状数组
    【BZOJ3730】震波 动态树分治+线段树
    【BZOJ2969】矩形粉刷 概率+容斥
    【BZOJ3029】守卫者的挑战 概率+背包
    【BZOJ3043】IncDec Sequence 乱搞
    【BZOJ3124】[Sdoi2013]直径 树形DP(不用结论)
    Django学习笔记之ORM多表操作
    SQL学习笔记之项目中常用的19条MySQL优化
  • 原文地址:https://www.cnblogs.com/qiqibo/p/2827877.html
Copyright © 2011-2022 走看看