在iPhone 3.0 SDK中改变了渐变技巧?

问题描述 投票:0回答:1

我正在使用一个技巧来获得表格单元格的渐变。

在我升级到iPhone 3.0 SDK之后,我注意到,当我选择一个单元格时,渐变突出显示不再有效。

iPhone 2.2.1

iPhone 3.0

这是渐变代码:

    - (void)drawContentView:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    UIColor *textColor = [UIColor whiteColor];

    // Apply gradient fill
    CGFloat locations[2] = { 0.0, 0.75 };
    CGFloat components[8] = {0.50, 0.50, 0.50, 1.0, // Start color
                             0.23, 0.23, 0.23, 1.0}; // End color 

    if (self.selected) {
        components[0] -= 0.10;
        components[1] -= 0.10;
        components[2] -= 0.10;
        components[4] -= 0.10;
        components[5] -= 0.10;
        components[6] -= 0.10;
    }

    CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();
    CGGradientRef myGradient = CGGradientCreateWithColorComponents (myColorspace, components, locations, 2);
    CGPoint start = CGPointMake(0, 0);
    CGPoint end = CGPointMake(0, rect.size.height);
    CGContextDrawLinearGradient(context, myGradient, start, end, 0);

    [textColor set];
    CGSize mainTextSize = [self.mainText sizeWithFont:(markedRead ? mainTextReadFont : mainTextFont) constrainedToSize:CGSizeMake(288, 200) lineBreakMode:UILineBreakModeWordWrap];
    [self.mainText drawInRect:CGRectMake(6, 4, mainTextSize.width, mainTextSize.height) withFont:(markedRead ? mainTextReadFont : mainTextFont)];

    [[UIColor lightGrayColor] set];
    [self.subText drawAtPoint:CGPointMake(6, mainTextSize.height + 2) forWidth:288 withFont:subTextFont lineBreakMode:UILineBreakModeTailTruncation];
}

如果不明显,qazxsw poi中的代码决定高亮颜色。 任何人都知道可能导致这种情况的原因,可能的解

iphone iphone-sdk-3.0 ios-simulator uicolor
1个回答
4
投票

其实自己解决了这个问题。

if (self.selected) { 已改为 if (self.selected) { 在iPhone 3.0中

© www.soinside.com 2019 - 2024. All rights reserved.