2009-08-08 8 views
0

私はテーブルセルにグラデーションをつけるためにトリックを使用しています。iPhone 3.0 SDKでグラデーショントリックが変更されましたか?

iPhone 3.0 SDKにアップグレードした後、グラデーションのハイライト表示がセルを選択しても機能しなくなったことに気づきました。

iPhone 2.2.1
​​

iPhone 3.0
http://i32.tinypic.com/2i6dnyp.jpg


ここ勾配コードです:

- (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]; 
} 

それが明らかでない場合は、if (self.selected) {のコードが決定したがhightlightの色です。


誰でも知っている可能性があります。解決策はありますか?

答えて

4

実際これを自分で解決しました。

if (self.selected) {
は実際に、あなたは `selected`(そしておそらく、あまりにも他の方法で回避)することなく、` highlighted`ことができるiPhone 3.0

+0


if (self.highlighted) {
に変更されました。私は通常、私の状態でチェックします。 – jbrennan

関連する問題