¿Se cambió el truco de gradiente en el SDK del iPhone 3.0?
-
12-09-2019 - |
Pregunta
Estoy usando un truco para obtener degradado en las celdas de mi tabla.
Después de actualizar al SDK de iPhone 3.0, noté que el resaltado de degradado, cuando selecciono una celda, ya no funciona.
Aquí está el código de gradiente:
- (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];
}
Si no es obvio, el código en if (self.selected) {
decide el color de resaltado.
¿Alguien sabe qué podría causar esto, posible solución?
Solución
En realidad resuelto este mismo.
if (self.selected) {
ha cambiado a
if (self.highlighted) {
en el iPhone 3.0
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow