2011-04-23 64 views
0

我正在嘗試編寫UILabel的外觀,但我無法獲得應用的其他字體。有趣的(或者說比較煩人的)事情是,如果我添加第二個UILabel,字體將被應用於第二個標籤,但不是第一個。我對此略微瘋狂......尤其是字體大小不會改變,如果我嘗試。cocoa-touch:爲什麼不應用字體?

我的代碼(在我viewDidLoad中找到):

NSString* dateWeekDay = @"MON"; 
CGRect dateWeekDayFrame = CGRectMake(183, 12, 34, 21); 
viewNoteDateWeekDay = [[UILabel alloc] initWithFrame:dateWeekDayFrame]; 
viewNoteDateWeekDay.text = dateWeekDay; 
viewNoteDateWeekDay.textColor = [UIColor blackColor]; 
viewNoteTitle.font = [UIFont fontWithName:@"Helvetica Neue" size:70.0f]; // I know this size is crazy, but it's just to show that it has no effect whatsoever... 
viewNoteDateWeekDay.transform = CGAffineTransformMakeRotation((-90 * M_PI)/180); 
viewNoteDateWeekDay.backgroundColor = [UIColor clearColor]; 

NSString* dateDay = @"01"; 
CGRect dateDayFrame = CGRectMake(209, 3, 47, 50); 
viewNoteDateDay = [[UILabel alloc] initWithFrame:dateDayFrame]; 
viewNoteDateDay.text = dateDay; 
viewNoteDateDay.textColor = [UIColor blackColor]; 
viewNoteDateDay.font = [UIFont fontWithName:@"Helvetica Neue" size:33.0f]; 
viewNoteDateDay.backgroundColor = [UIColor clearColor]; 

NSString* dateMonth = @"SEPTEMBER"; 
CGRect dateMonthFrame = CGRectMake(249, 6, 93, 31); 
viewNoteDateMonth = [[UILabel alloc] initWithFrame:dateMonthFrame]; 
viewNoteDateMonth.text = dateMonth; 
viewNoteDateMonth.textColor = [UIColor blackColor]; 
viewNoteDateMonth.font = [UIFont fontWithName:@"Helvetica Neue" size:12.0f]; 
viewNoteDateMonth.backgroundColor = [UIColor clearColor]; 

enter image description here

回答

1

您指定了錯誤的變量名,當你設置字體屬性。你的代碼說:viewNoteTitle.font = ...當它應該閱讀viewNoteDateWeekDay.font = ...

+0

謝謝...有時你根本無法思考直線了。非常感激你的幫助! – 2011-04-23 19:32:08

+0

我的榮幸。獲得第二套眼睛總是有幫助的。 – Kyle 2011-04-23 19:59:44

相關問題