Dentro la mia domanda ho utilizzare un CAGradientLayer
per impostare lo sfondo della mia cella, in questo modo:CAGradientLayer orizzontale in iOS 7.0
retValue = [tableView dequeueReusableCellWithIdentifier:@"Cells" forIndexPath:indexPath];
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor blueColor];
bgColorView.layer.masksToBounds = YES;
id startColor = (id)[[UIColor colorWithWhite:0.75 alpha:1] CGColor];
id endColor = (id)[[UIColor blueColor] CGColor];
CAGradientLayer* gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = retValue.contentView.bounds;
gradientLayer.colors = @[startColor,startColor,endColor,endColor];
gradientLayer.locations = @[[NSNumber numberWithFloat:0],
[NSNumber numberWithFloat:0.95],
[NSNumber numberWithFloat:0.95],
[NSNumber numberWithFloat:1]];
[gradientLayer setStartPoint:CGPointMake(0,0.5)];
[gradientLayer setEndPoint:CGPointMake(1,0.5)];
[bgColorView.layer addSublayer:gradientLayer];
retValue.selectedBackgroundView = bgColorView;
(questo codice si trova all'interno - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
)
Funziona bene su iOS 6 ma non funziona su iOS 7, nel nuovo iOS il gradiente è sempre verticale (startPoint e endpoint vengono ignorati)
qualcuno ha riscontrato nello stesso problema?
Grazie,
Perry
Si noti che '[UIColor clearColor]' crea una strana sfumatura di grigio. Come questa risposta, usa invece '[UIColor colorWithWhite: 1.0 alpha: 0.0]'. Questo ti darà un gradiente trasparente. –