【代碼筆記】設定textView或者label的行間距方法,textviewlabel

來源:互聯網
上載者:User

【代碼筆記】設定textView或者label的行間距方法,textviewlabel

一,。

二,代碼。

RootViewController.m

- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view.        //UILabel    UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 300)];    label.backgroundColor=[UIColor orangeColor];    label.text=@"公元前3000年,印度河流域的居民的數字使用就已經比較普遍,居民們採用了十進位制的計演算法。到吠陀時代(公元前1500~公元前500年),雅利安人已意識到數字在生產活動和日常生活中的作用,創造了一些簡單的、不完全的數字。公元前3世紀,印度出現了整套的數字,但各地的寫法不一,其中最典型的是婆羅門式,它的獨到之處就是從1~9每個數都有專用符號,現代數字就是從它們中脫胎而來的。當時,“0”還沒有出現。到了笈多時代(300~500年)才有了“0”,叫“舜若”(shunya),表示方式是一個黑點“●”,後來衍變成“0”。這樣,一套完整的數字便產生了。這項勞動創作也對世界文化做出了巨大的貢獻。";    label.numberOfLines=0;    [self.view addSubview:label];        //設定行間距    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];    paragraphStyle.lineSpacing = 50;        NSDictionary *attributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSParagraphStyleAttributeName:paragraphStyle};    label.attributedText = [[NSAttributedString alloc]initWithString:label.text attributes:attributes];}

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.