开发者

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

开发者 https://www.devze.com 2023-01-13 21:59 出处:网络
i was just wondering if there was a way to c开发者_开发技巧hange the fontSize of a row in a uipickerview

i was just wondering if there was a way to c开发者_开发技巧hange 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号