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) {
Hightlight 색상을 결정합니다.
누구든지 이것이 원인이 무엇인지, 가능한 해결책을 아는 사람이 있습니까?
해결책
실제로 이것을 직접 해결했습니다.
if (self.selected) {
변경되었습니다
if (self.highlighted) {
iPhone 3.0에서
제휴하지 않습니다 StackOverflow