UILabel垂直方向显示(上下的顺序显示)。

NSString* text = @"一";

NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:16]};

CGSize size = [text boundingRectWithSize:CGSizeMake(1000, 90) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;

CGFloat w = size.width+2;//一个汉字的宽度加2 ,要不然会显示残缺

text = @"如题,我们平时习惯的用法是将text以左右顺序呈现在UILabel上,那么有什么方法能让text以上下的顺序显示呢? ";

//    CGSize asize = [text sizeWithFont:font constrainedToSize:CGSizeMake(w, MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];

//老的方法已经弃用了。

CGSize asize = [text boundingRectWithSize:CGSizeMake(w, MAXFLOAT) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:attribute context:nil].size;

CGFloat h = asize.height;

UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(100,10,w,h)];

lable.text = text;

lable.numberOfLines = 0;

[self.view addSubview:lable];

时间: 2024-08-06 05:47:32

UILabel垂直方向显示(上下的顺序显示)。的相关文章

控制UIlabel 垂直方向对齐方式的 方法

最正统的方法,利用objective-c的category特性,修改UILabel的绘制代码.示例代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 // -- file: UILabel+VerticalAlign.h #pragma mark VerticalAlign @interface UILabel (VerticalAlign) - (void)alignTop; -

MySQL查询in操作 查询结果按in集合顺序显示_Mysql_脚本之家

body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI",Tahoma,Helvetica,Sans-Serif,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLiU,serif; font-size: 10.5pt; line-height: 1.5;

开启3个线程,这3个线程的ID分别为A、B、C,每个线程将自己的ID在屏幕上,要求输出结果必须按ABC的顺序显示:ABCABC

分类: windows编程 C++ 2012-10-27 15:38 3270人阅读 评论(6) 收藏 举报 第四题(迅雷笔试题):编写一个程序,开启3个线程,这3个线程的ID分别为A.B.C,每个线程将自己的ID在屏幕上打印10遍,要求输出结果必须按ABC的顺序显示:如:ABCABC….依次递推. [cpp] view plaincopy #include <stdio.h> #include <process.h> #include <windows.h> #def

自定义UILabel设置垂直方向的居上,居中,居下

IOS系统框架中UILabel的属性textAlignment只调整水平方向的居中,居左,居右,而没有垂直方向的调整.所以要自定义一个继承自UILabel的类,在类的实现文件中进行文字的重绘,达到垂直方向的位置调整. 新建一个类文件,继承自UILabel,头文件如下: #import <UIKit/UIKit.h> typedef NS_ENUM(NSInteger,VerticalAlignment){ VerticalAlignmentTop, VerticalAlignmentMiddl

[Swift Weekly Contest 113]LeetCode950. 按递增顺序显示卡牌 | Reveal Cards In Increasing Order

In a deck of cards, every card has a unique integer.  You can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in one deck. Now, you do the following steps repeatedly, until all cards are revealed: Take the

触发bfc解决父子元素嵌套垂直方向margin塌陷问题

首先看一下问题案例 .wrapper{ width: 100px; height: 100px; background-color: aqua; margin-top: 100px; margin-left: 100px; } .inner{ width: 50px; height: 50px; margin-top: 100px; margin-left: 50px; background-color:black; } <div class="wrapper"> <

iframe 内显示的网页 只显示改网页的某一部分!

使用iframe调用指定网页的特定位置(显示目标网页某区域的我想要的内容) 有些时候我们并不需要显示iframe标签属性src指定的目标网页的所有内容,往往只需要显示某一特定区域.现有两种实现方法提供,但严禁使用此方法用于欺骗.隐瞒目的. 这里用到了Iframe的一些属性,稍微介绍下:        1. marginheight 属性规定框架内容与框架的上方和下方之间的高度,以像素计.        2. maiginweidth 属性规定框架内容与框架的左侧和右侧之间的高度,以像素计.  

Unity3D开发安卓应用如何设置横屏显示和竖屏显示

说起 Unity3D 开发安卓应用设置屏幕方向,大家肯定都知道在发布的时候可以设置,也就是在下图所示的位置设置,分别表示:正向竖屏显示.倒向竖屏显示.右横屏显示.左横屏显示.跟随手机自动旋转.图一是设置屏幕显示的正方向,图二是设置允许显示的方向. 而且网上基本上也都是介绍的这种办法.这种方法有个弊端,就是设置了横屏或者竖屏后,那么应用在运行过程中,就是永远是横屏或者竖屏显示,无法更改. 博主我这次在开发项目中,拿到的需求是有些场景下横屏显示,有些场景下竖屏显示,这就太尴尬了,用上面的方法根本行不

js数据显示在文本框中(页面加载显示和按钮触动显示)

web代码如下: <!DOCTYPE html> <html> <head> <title>jsTest02.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is