---
title: "ios iphone UILabel 多行文字自动换行 （自动折行）"
author: "ynial"
date: "2011-11-23T11:29:08Z"
tags: []
categories: ["移动开发"]
slug: "ios-iphone-uilabel"
draft: false
lastmod: "2011-11-23T11:29:08Z"
id: 1274087
url: "https://ynial.iteye.com/blog/1274087"
---

【UILabel 自动换行】：


```java

UIView *footerView = [[uiview alloc] initWithFrame:CGRectMake(10, 100, 300, 180)];
    UILabel *label = [[uilabel alloc] initWithFrame:CGRectMake(10, 100, 300, 150)];
    label.text = @"where are you? where are you? where are you? where are you? where are you? where are you? where are you? where are you? where are you? where are you?";
    //清空背景颜色
    label.backgroundColor = [uicolor clearcolor];
    //设置字体颜色为白色
    label.textColor = [uicolor whitecolor];
    //文字居中显示
    label.textAlignment = UITextAlignmentCenter;
    //自动折行设置
    label.lineBreakMode = UILineBreakModeWordWrap;
    label.numberOfLines = 0;

```