阅读背景:

绘制渐变矩形的一种方法

来源:互联网 
- (void)drawRect:(CGRect)rect {
    // Drawing code
    [super drawRect:rect];
    
    //draw wings
    [[UIColor blackColor] set];
    CGFloat tempYPlace = self.currentSelectionY;
    if (tempYPlace < 0.0) {
        tempYPlace = 0.0;
    } else if (tempYPlace >= self.frame.size.height) {
        tempYPlace = self.frame.size.height - 1.0;
    }
    CGRect temp = CGRectMake(0.0, tempYPlace, self.frame.size.width, 1.0);
    UIRectFill(temp);
    
    //draw central bar over it
    CGFloat cbxbegin = self.frame.size.width * 0.2;
    CGFloat cbwidth = self.frame.size.width * 0.6;
    for (int y = 0; y < self.frame.size.height; y++) {
        [[UIColor colorWithHue:(y/self.frame.size.height) saturation:1.0 brightness:1.0 alpha:1.0] set];
        CGRect temp = CGRectMake(cbxbegin, y, cbwidth, 1.0);
        UIRectFill(temp);
    }
}
- (void)drawRect:(CGRect)rect {
    // Drawing 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: