简体   繁体   中英

Iphone Sdk: UIPickerView, possible to assign different font sizes to different components?

i was just wondering if there was a way to change the fontSize of a row in a uipickerview for a specific component and not for all of them. Also the different components still have to be able to display different things and not the same. Does anyone have a solution for this problem? Thanks in advance!

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view 
{
        UILabel *lbl = (UILabel *)view;
        // Reuse the label if possible...
       if ((lbl == nil) || ([lbl class] != [UILabel class])) {
            CGRect frame = CGRectMake(0.0, 0.0, 270, 32.0);
           lbl = [[[UILabel alloc] initWithFrame:frame] autorelease];

                .... do what you like ...

        }   
        lbl.textColor = [UIColor blackColor];
           lbl.text = [self.<yourdata> objectAtIndex:row];
        return lbl; 
}

The calling parameters tell you which view, row and component you are setting. Check them and set the appropriate thing only if both the row and component match (compare and use flow control) what you want for that row and component.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM