zoukankan      html  css  js  c++  java
  • uilabel自动换行

    NSString *str = @"我是一asdf我是一我是一我是一我是一我是一我是一我是一我是一我是一我是一我是一asdf我是一asdf我是一asdf我是一asdf我是一asdf我是一asdf";    
        CGSize labelSize = [str sizeWithFont:[UIFont boldSystemFontOfSize:17.0f]
                           constrainedToSize:CGSizeMake(280, 100) 
                           lineBreakMode:UILineBreakModeCharacterWrap];   // str是要显示的字符串
        UILabel *patternLabel = [[UILabel alloc] initWithFrame:CGRectMake(35, 157, labelSize.width, labelSize.height)];    
        patternLabel.text = str;
        patternLabel.backgroundColor = [UIColor clearColor];
        patternLabel.font = [UIFont boldSystemFontOfSize:17.0f];
        patternLabel.numberOfLines = 0;// 不可少Label属性之一
        patternLabel.lineBreakMode = UILineBreakModeCharacterWrap;// 不可少Label属性之二
        [self.view addSubview:patternLabel];

  • 相关阅读:
    最短母串
    noip模拟测试7
    linux下的对拍程序
    noip模拟测试6
    QWidget 前后位置设定
    C++编程规范_第5~13条 设计风格
    random /timer/sort 示例代码
    资料准备
    【转】三维动态数组 分配与释放
    批量修改文件名
  • 原文地址:https://www.cnblogs.com/yulang314/p/3793555.html
Copyright © 2011-2022 走看看