0
我有這種方法來製作一個字體選擇器和一個當前不可用的字體的圖像。出於某種原因,它在iOS 6上顯示得非常好,但圖像在iOS 7上完全不顯示。我不知道爲什麼會出現這種情況。我聽說過有關iOS 7可怕選擇器視圖的恐怖故事,這些故事會給人們帶來嚴重問題,但我希望自己不會成爲其中的一員。有沒有人知道一種方法來完成這項工作?iOS 7 UIPickerView沒有顯示它應該是什麼,iOS 6 UIPickerView的
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UIFont *newFont = [UIFont fontWithName:[self.fonts objectAtIndex:row] size:kFontPickerPointSize];
NSDictionary *attributes;
if (([self isAvailable] == YES) || (row < kMinAvailableIndex)){
attributes = @{NSFontAttributeName:newFont, NSForegroundColorAttributeName:[UIColor blueColor]};
} else if ([self isAvailable] == NO){
attributes = @{NSFontAttributeName:newFont,NSForegroundColorAttributeName:[UIColor grayColor]};
}
NSString *fontName = newFont.fontName;
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:fontName attributes:attributes];
UILabel *rowView = [[UILabel alloc] initWithFrame:view.frame];
[rowView setAttributedText:attributedString];
if ([self isAvailable] == NO && row >= kMinAvailableIndex){
UIImageView *rowImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pickerRowImage"]];
[rowImage setFrame:CGRectMake(0, 0, rowView.frame.size.height, rowView.frame.size.height)];
[rowView addSubview:rowImage];
}
return rowView;
}