Dinakar
Dinakar

Reputation: 1208

wanted the font size of a textLabel to be scaled according to the text on the view

i am developing a app where i get data from xml and i parse them and use it in application.I get a text to be placed in a textField along with font style and size from xml.This xml is generated on a system which runs on windows. situation: i have a situation where i am getting the font size as 8 from xml and after parsing and displaying the text in the textField the text size looks very small almost like ants.Where as the text with the same font and same size looks neat and clear on desktop.

Is there any scaling mechanism which enables me to scale the text size to a bigger size which makes it visible easily without me increasing the size of the font .

TNQ

Upvotes: 0

Views: 207

Answers (2)

jrturton
jrturton

Reputation: 119292

You can find out the size (as a CGSize) that a string of a certain font will be using NSString's drawing methods (sizeWithFont: and variations). Use this together with the size of your label to determine the correct font size to use.

Upvotes: 0

Akshay
Akshay

Reputation: 5765

I think font size = 8 is actually quite small. Perhaps you could scale the value that you receive from the server by a scale factor (say 1.5 or 2).

NSUInteger SCALE_FACTOR = 2;
textField.font = [UIFont systemFontOfSize:SCALE_FACTOR * xmlValue]; //xmlValue is the value you get from the server

HTH,

Akshay

Upvotes: 1

Related Questions