iPhone 3.0 SDKでグラデーショントリックが変更されましたか?
-
12-09-2019 - |
質問
テーブルのセルにグラデーションを適用するトリックを使用しています。
iPhone 3.0 SDK にアップグレードした後、セルを選択したときのグラデーション強調表示が機能しなくなっていることに気付きました。
グラデーションコードは次のとおりです。
- (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) {
ハイライトの色を決定します。
これの原因と考えられる解決策を知っている人はいますか?
解決
実はこれを自分で解決します。
if (self.selected) {
に変更されました
if (self.highlighted) {
iPhone 3.0での
所属していません StackOverflow