2012-05-19 234 views
0

我正在使用其中传递了对象数组的textview。在那个数组中,我已经获得了将传递给textview的消息列表,但我已经改变了textview字体的大小。给出适用于我的应用程序的任何建议和源代码。如何在我的文本视图中更改字体大小

在我的代码下面我已经应用了UIFont,但这不是在字体中使用。

msgtxtView.text=selectedmsg; 
[msgtxtView setFont:[UIFont fontWithName:@"Arial" size:10]] 

selectedmsg是在该消息列表对象的阵列,其将传递给TextView的的对象,但输出的字体大小和arialfont不起作用给出任何。

回答

0

使用此:

msgtxtView.text=selectedmsg; 
[msgtxtView setFont:[UIFont fontWithName:@"ArialMT" size:10]] 
+0

他是用正确的字体名称:** ** Arial字体。 –

0

看看他的例子,如何从阵列和改变大小添加文字(您正确地改变大小):

NSMutableArray *array = [NSMutableArray arrayWithObjects:@"message1", @"message2", @"message3", @"message4", @"message5", nil]; 

for (int i=0; i<[array count]; i++) { 
    msgtxtView.text = [NSString stringWithFormat:@"%@%@\n",msgtxtView.text,[array objectAtIndex:i]]; 
} 

[msgtxtView setFont:[UIFont fontWithName:@"Arial" size:10]]; 

不要忘记IBOutlet中 msgtxtView 。

结果:

enter image description here

再举例来说,使用这样的:[UIFont fontWithName:@"Chalkduster" size:25]

enter image description here

相关问题