我正在尝试编写UILabel的外观,但我无法应用另一种字体。有趣(或者说很烦人)的事情是,如果我添加第二个UILabel,第二个标签的字体将被应用,但不是第一个。我有点疯狂......特别是如果我尝试的话,字体大小不会改变。
我的代码(在我的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];
答案 0 :(得分:1)
在设置font属性时指定了错误的变量名。您的代码显示为:viewNoteTitle.font = ...
,应该显示viewNoteDateWeekDay.font = ...