常用属性UILabel
//显示的文字
@property(nonatomic,copy)   NSString           *text;
//字体
@property(nonatomic,retain) UIFont             *font;
//文字颜色
@property(nonatomic,retain) UIColor            *textColor;
//对齐模式(比如左对齐、居中对齐、右对齐)
@property(nonatomic)        NSTextAlignment    textAlignment;

[label setTextAlignment:NSTextAlignmentCenter]; //文字显示的位置

self.titleLabel.font = [UIFont systemFontOfSize:12]; //文字的大小
/根据字体大小、宽度、换行模式获得字体的高度

NSString *str = self.textLabel.text;

CGSize textSize = [str sizeWithFont:UIFont systemFontOfSize:14.0] constrainedToSize:CGSizeMake(w, 10000)

lineBreakMode:NOLine];

CGFloat h = textSize.height;
[_textLabel setNumberOfLines:0]; //自动换行

iOS-UILabel的使用的更多相关文章

  1. iOS UILabel UITextView UIButton 等等显示文本行间距

    iOS UILabel  UITextView UIButton 等等显示文本行间距都用如下方法 NSMutableParagraphStyle *paragraphStyle = [[NSMutab ...

  2. iOS UILabel 文字 置顶/置底 实现

    iOS UILabel控件默认文字位置是居中的,如图所示: 但是我们经常碰到这样的需求,希望文字向上置顶,或者向下置底,但是很遗憾,iOS API中并没有提供相应的属性和方法,需要我们手动设置. 利用 ...

  3. IOS UILabel 根据内容自适应高度

    iOS Label 自适应高度  适配iOS7以后的版本 更多 self.contentLabelView = [[UILabel alloc] init]; self.contentLabelVie ...

  4. iOS - UILabel

    前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UILabel : UIView <NSCoding> @available(iOS 2.0, *) p ...

  5. iOS UILabel设置居上对齐,居中对齐,居下对齐

    在iOS中默认的UILabel中的文字在竖直方向上仅仅能居中对齐,博主參考国外站点.从UILabel继承了一个新类,实现了居上对齐,居中对齐,居下对齐.详细例如以下: // //  myUILabel ...

  6. ios - UILabel全属性

    label是大家在开发过程中使用频率很高的一个用来显示文本信息的控件,但是她所有的属性你都了解吗,下面让我们来 重新认识一下label! 1.创建 CGRect rect = CGRectMake(, ...

  7. iOS -- UILabel的常见使用

    UILabel是iOS开发经常用到的一个控件,主要用于显示文字.下面记录一些常用的UIlabel的使用. 先定义:UILabel *label = [[UILabel alloc]initWithFr ...

  8. iOS · UILabel加删除线

    创建自定义子类DeleteLineLabel,继承自UILabel,然后在自定义子类DeleteLineLabel中 方法一(上下文): - (void)drawRect:(CGRect)rect { ...

  9. (转载)iOS UILabel自定义行间距时获取高度

    本文介绍一下自定义行间距的UILabel的高度如何获取,需要借助一下开源的UILabel控件:TTTAttributedLabel 附下载地址 https://github.com/TTTAttrib ...

  10. iOS UILabel根据字符串长度自动适应宽度和高度

    //这个frame是初设的,没关系,后面还会重新设置其size.     UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0, ...

随机推荐

  1. Meeting Rooms II

    Description Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2, ...

  2. MongoDB 系统分析器

    1.1 系统分析器作用 可以利用系统分析器(system profiler)来查找耗时过长的操作. 系统分析器可记录特殊集合system.profile中的操作,并提供大量有关耗时长的操作信息,但相应 ...

  3. CSP-S 2019 D1T2 括号树

    题目链接:[https://www.luogu.com.cn/problem/P5658] 思路: 这道题不难.(为什么我在考场上一点思路也没有??) 假设我们已经处理到树上的节点u(假设1为根节点) ...

  4. Redis学习之一--基础知识

    一.定义 REmote DIctionary Server(Redis) 是一个以字典结构存储数据的key-value存储系统:使用ANSI C语言编写.遵守BSD协议.支持网络.可基于内存亦可持久化 ...

  5. 如何实现一个 windows 桌面动态壁纸

    ​ 更新: 2018/08/31 WS_MOUSE_LL 钩子,实现底层壁纸交互效果. 一.介绍 国内玩家第一次看到动态壁纸,都是出于一款来自 Wallpaper Engine 的 Steam 程序. ...

  6. 数据结构实验之查找四:二分查找(SDUT 3376)

    #include <stdio.h> #include <string.h> #include <stdlib.h> int a[1000005]; int fin ...

  7. (转)Redis Cluster(集群)

    一.概述 在前面的文章中介绍过了redis的主从和哨兵两种集群方案,redis从3.0版本开始引入了redis-cluster(集群).从主从-哨兵-集群可以看到redis的不断完善:主从复制是最简单 ...

  8. elasticsearch update方法报错: Too many dynamic script compilations within, max: [75/5m]

    PUT _cluster/settings    {        "transient" : {            "script.max_compilations ...

  9. sonca排除不扫描文件

    在pom.xml文件中的<properties>标签下加上<sonar.exclusions>XXX</sonar.exclusions>标签,如下 <pro ...

  10. checkbox后台传个list显示和回显的页面代码C标签

        <c:forEach items="${listtest}" var="provinces">        <input type= ...