开发者

UITableViewCell Highlights & Effects

So I have a tableview with 8 cells containing 8 uitextfields as subviews to each cell. It's basically like a form that the user needs to fill up and I want some effects while the user starts typing.

When TextFieldDidBeginEditing method gets called, I want that corresponding UITableViewCell to be highlighted, and all other UITableViewCells to be sort-of 'Dimmed' . This effect makes the User Focus on the particular textField he is typing in, and开发者_开发问答 I am trying to implement this in my code.

Is this possible ? I would appreciate it if anyone could help me with this EFFECT !


Here you go:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray*cells = [_regTable visibleCells];

    UITableViewCell*currentcell = [_regTable cellForRowAtIndexPath:indexPath];

    for (UITableViewCell*cell in cells)
    {
        if ([cell isEqual:currentCell] == NO) //You'll have to think on how to distinguish a selected cell from an unselected one - if you go the default way then that's how its done
        {
            [UIView beginAnimations:nil context:NULL]; 
            [UIView setAnimationDuration:0.5]; 
            cell.alpha = 0.5;
            [UIView commitAnimations];
        }
        else
        {
            [UIView beginAnimations:nil context:NULL]; 
            [UIView setAnimationDuration:0.5]; 
            cell.alpha = 1.0;
            [UIView commitAnimations];
        }

    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜