2012-06-11 2 views
2

두 테이블 셀 배경색을 빨간색에서 원래 색 (흰색)으로 다시 애니메이션하려고합니다.블록 애니메이션에서 UITableViewCell의 backgroundColor 애니메이션하기

다음 코드는 내가 사용하고있는 코드입니다. 문제는 붉은 색을 결코 보여주지 않는다는 것입니다. 단순히 흰색으로부터 (원래의) 흰색에서 (움직이는 것까지) 흰색으로 움직입니다. 즉, 애니메이션 블록에서 색상을 변경하면 해당 색상으로 애니메이션이 적용됩니다. 내가 원하는 테이블의 배경에 대해 예상대로

[table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]].backgroundColor = [UIColor redColor]; 
[table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]].backgroundColor = [UIColor redColor]; 

[UIView animateWithDuration:0.8 delay:0.2 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 
    [table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]].backgroundColor = [UIColor whiteColor]; 
    [table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]].backgroundColor = [UIColor whiteColor]; 
} 
completion:^(BOOL finished) { 

}]; 

다음 코드는 작동하지만, 그건 아니다 :

그래서
table.backgroundColor = [UIColor redColor]; 

[UIView animateWithDuration:0.8 delay:0.2 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 
    table.backgroundColor = [UIColor clearColor]; 
} 
completion:^(BOOL finished) { 

}]; 

, 이유는 무엇입니까 내 테이블 배경은하지 않습니다 내 휴대 배경 애니메이션?

내가보기에이 테이블 뷰에서 수행하는 일련의 다른 연결된 애니메이션이 있지만 그 애니메이션에 주석을 달았지만 여전히이 문제가 있습니다.

+0

TableView 셀은 배경색과 같은 종류의 마법입니다. 'tableView : willDisplayCell : forRowAtIndexPath :'메소드와 다른 곳에서는 (UIView'의'backgroundColor' 속성을 통해) 배경색을 설정할 수 있습니다. 자세한 내용은 설명서를 참조하십시오. https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006938 –

답변

0

@Jason Coco가 옳다. 나는 (깔끔하게 빠르게)을 수행 할 수 없습니다 애플에서

:

참고 : 당신은을 통해 셀의 배경 색상을 설정하여 셀 (의 배경색을 변경하려면 UIView에 의해 backgroundColor 속성 이 선언 됨) 위임자 의 tableView : willDisplayCell : forRowAtIndexPath : 메서드에서 수행해야하며 데이터 소스의 tableView : cellForRowAtIndexPath :가 아니어야합니다. 그룹 스타일 테이블보기에서 셀의 배경색을 변경하면 은 이전 버전 인 운영 체제와 다른 iOS 3.0에서 적용됩니다. 이제 외부 영역 대신 반올림 된 직사각형 영역에 영향을줍니다. 나는 몇 가지 변수를 설정해야 할 것에 Reference

그래서 내가 정말 원하는 경우, 다음 테이블 또는 비슷한에 reloadData를 호출합니다.

0

셀에 다른보기가 포함되어 있기 때문입니다. cell.contentView, cell.accessoryViewcell.backgroundView의 색상을 확인해야합니다. 이들 모두가 [UIColor clearColor] 인 경우 cell.backgroundColor 만 움직이면됩니다.

+0

이것은 작동하지 않았습니다. 나를 위해. –

관련 문제