Author Topic: UILabel problem  (Read 2262 times)

Magic Frame

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
UILabel problem
« on: July 04, 2014, 04:38:38 AM »
hi, I'm creating an app where I can watch news, the news sent through a database and then the app download the news .... the problem is that the UILabel text format is horrible, I can not do line break? add bold? etc ... for example when the database put a paragraph and I add "\ n" does not line break ... any suggestions

Fireball14

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 23
    • View Profile
Re: UILabel problem
« Reply #1 on: July 04, 2014, 06:08:23 AM »
Use Environment.NewLine
http://msdn.microsoft.com/en-us/library/system.environment.newline

As for bold and other properties, you can only specyfy proporty for whole UILabel component. If you want to change only one part of text, brake string on two parts and use two separate UIlabels to show them. And to change style of a text, use properties like UILabel.Effect and others.

More on http://www.tasharen.com/ngui/docs/class_u_i_label.html

Magic Frame

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel problem
« Reply #2 on: July 04, 2014, 10:37:06 AM »
No, not work, I need the line break, the doc say that I want line break I have use this command "\n" but not work… repeat I download the text from a database. For the bold , italic and other things, work well with bbcode. thanks and sorry for my english

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel problem
« Reply #3 on: July 04, 2014, 02:50:34 PM »
If your text comes from the database, then your "\n" is going to be 2 characters, not one. When specified in code, "\n" sequence gets replaced with a NewLine character, which is 1 character, not 2. That's how line breaks are made.

So when assigning your text in code, after you retrieve it from your database, do a string.Replace("\\n", "\n").