UIDatePicker

// clear the background of the main subviewUIView*view =[[datePicker subviews] objectAtIndex:0];[view setBackgroundColor:[UIColor clearColor]];// hide the first and the last subviews[[[view subviews] objectAtIndex:0] setHidden:YES];[[[view subviews] lastObject] setHidden:YES];

- (void)drawRect:(CGRect)rect {
    UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 234)];
    img.image = [UIImage imageNamed:@"picker_small.png"];
    [self addSubview:img];
    [img release];
    
    //4-选择区域的背景颜色; 0-大背景的颜色; 1-选择框左边的颜色; 2-? ;3-?; 5-滚动区域的颜色 回覆盖数据
    //6-选择框的背景颜色 7-选择框左边的颜色 8-整个View的颜色 会覆盖所有的图片
    UIView *v = [[self subviews] objectAtIndex:6];
    [v setBackgroundColor:[UIColor clearColor]];
    UIImageView *bgimg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"picker_tiao.png"]];
    bgimg.frame = CGRectMake(-5, -3, 200, 55);
    [v addSubview:bgimg];
    [bgimg release];
    
    [self setNeedsDisplay];
    
}

猜你喜欢

转载自shappy1978.iteye.com/blog/1902526
今日推荐