//label自适应

self.label = [UILabel new];

self.label.font = [UIFont systemFontOfSize:14];

NSString *titleContent = @"亲,欢迎您通过以下方式与我们的营销顾问取得联系,交流您再营销推广工作中遇到的问题,营销顾问将免费为您提供咨询服务。亲,欢迎您通";

self.label.text = titleContent;

self.label.textAlignment = NSTextAlignmentRight;

self.label.textColor = [UIColor redColor];

self.label.numberOfLines = 0;//多行显示,计算高度

CGSize titleSize = [titleContent boundingRectWithSize:CGSizeMake(self.view.frame.size.width -80, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;

self.label.frame = CGRectMake(40,40, titleSize.width, titleSize.height);

[self.view addSubview:self.label];

label自适应的更多相关文章

  1. iOS Label 自适应高度

    推荐第二个 测试一,只改变numberOfLines属性,label的高度不会自适应(会有text中的一部分内容称为......) NSString *str = @"jgreijgirje ...

  2. TableView中Label自适应高度

    //Xcode6.3以后label自适应需要添加两个属性 _tableView.rowHeight = UITableViewAutomaticDimension; //给予预计行高 _tableVi ...

  3. label自适应文本大小

    UILabel *label = [[UILabelalloc] initWithFrame:CGRectZero]; NSString *string = @"aa2fkoksdajfis ...

  4. Label自适应高度的用法及设置倒角

    UILabel *label = [[UILabel alloc] init]; //根据内容动态计算label的高度 label.text = @"Sent when the applic ...

  5. Label 自适应文本(StoryBoard/xib)

    To make your label automatically resize height you need to do following: Set layout constrains for l ...

  6. Label自适应高度

    每次都逼我翻代码   这次干脆写博客里面算了 哈哈哈 CGSize maxSize = CGSizeMake(ScreenWith-30,NSIntegerMax); CGSize labelsize ...

  7. 27、Label 自适应文本 xib

    第一步: 第二步: 第三步: 第四步:

  8. iOS textFiledView,label自适应高度

    CGSize constraintSize; constraintSize.width = 320; constraintSize.height = MAXFLOAT; CGSize sizeFram ...

  9. ios label根据内容自适应高度

    label自适应高度,想必大家也都很熟悉怎么去做,上代码: UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(150, 50, 15 ...

随机推荐

  1. 微信小程序Tabbar文字在真机不显示

    按照官方文档在json中定义好了Tabbar后,在模拟器上显示没问题,而在真机上不显示Tabar文字. 让我很苦笑不得的原因是: 在app.json定义Tabbar文字选中态和非选中态颜色时我用了英文 ...

  2. 第八十三节,CSS3动画效果

    CSS3动画效果 学习要点: 1.动画简介 2.属性详解 3.简写和版本 本章主要探讨HTML5中CSS3的动画效果,可以通过类 Flash那样的关键帧模式控制运行. 一.动画简介     CSS3提 ...

  3. 数据库DateTime类型为空的处理

    一,写一个辅助类,将该方法设为静态,先装换为object,在转为DateTime,返回DateTime public class DateTimeHelper { public static Date ...

  4. "ApplicationDbContext"(泛指之类的数据库上下文模型)上下文的模型已在数据库创建后发生更改。请考虑使用 Code First 迁移更新数据库。

    一,在我使用自动生成数据库的时候,当你改变了数据库就会出现下面问题 "ApplicationDbContext"(泛指之类的数据库上下文模型)上下文的模型已在数据库创建后发生更改. ...

  5. 【LeetCode】2.Add Two Numbers

    首先想到的是走到其中一个链表的尽头,然后把剩余的链表中的值放入写的链表,返回,但是自己写的代码好长. struct ListNode* addTwoNumbers(struct ListNode* l ...

  6. opkg

    opkg是个安装器,小乔,功能全. root@hbg:/# opkg files opkgPackage opkg (9c97d5ecd795709c8584e972bfdf3aee3a5b846d- ...

  7. 极光推送 PHP sdk

    <?php defined('IN_WZ') or exit('No direct script access allowed'); /** * Created by PhpStorm. * U ...

  8. Python 学习笔记10

    念念不忘,必有回响. 今天继续学习Python 类.

  9. Laravel框架开发规范-修订前期版

    1.追加App/Models目录,App/User.php迁移至App/Models目录中 ①配置内容属于架构信息.服务器信息.有必要隐藏无法提交git的信息,请使用.env文件配合env()方法进行 ...

  10. 重复T次的LIS的dp Codeforces Round #323 (Div. 2) D

    http://codeforces.com/contest/583/problem/D 原题:You are given an array of positive integers a1, a2, . ...