당신이 묘사하고있는 것 (나는 믿는다)의 완전한 기능적 예입니다. 빈 단일 뷰 프로젝트를 열고 스토리 보드에서 뷰 컨트롤을 삭제하고 단순히 UITableViewController를 만들고 그 클래스를 아래에 만든 UITableViewController 하위 클래스의 클래스로 설정했습니다.
는 헤더 파일에 추가 어디에도 없습니다, 그래서 그것을 이미 표시되는 뷰의 인덱스에 포함됩니다
#import "weeeTables.h"
@interface weeeTables()
@property (nonatomic, strong) NSMutableSet *shownIndexes;
@property (nonatomic, assign) CATransform3D initialTransform;
@end
shownIndexes 제외했습니다, 그래서 우리는 다시 스크롤 애니메이션을 반복하지 않는다. initialTransform 속성은이
있는 viewDidLoad에서
@implementation weeeTables
- (void)viewDidLoad {
[super viewDidLoad];
CGFloat rotationAngleDegrees = -30;
CGFloat rotationAngleRadians = rotationAngleDegrees * (M_PI/180);
CGPoint offsetPositioning = CGPointMake(-20, -20.0);
CATransform3D transform = CATransform3DIdentity;
transform = CATransform3DRotate(transform, rotationAngleRadians, -50.0, 0.0, 1.0);
transform = CATransform3DTranslate(transform, offsetPositioning.x, offsetPositioning.y, -50.0);
_initialTransform = transform;
_shownIndexes = [NSMutableSet set];
}
, 우리는 설정 초기의 값이 변환 (이 화면에 오기 전에 당신이 그것을 원하는 위치) 셀의 초기 상태에 대한, 내가 값을 비트와 함께 연주 변환입니다 찾고있는 효과를 얻으려면 동일한 작업을 수행하는 것이 좋습니다. 그러나 셀은 현재 왼쪽 하단 모서리에서 애니메이션을 적용합니다. 위의 블록
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 20;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 385;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"weeCell" forIndexPath:indexPath];
return cell;
}
모든 것이있는 UITableViewController 하위 클래스에 대한 매우 일반적인, 그리고 애니메이션을 추가하는 특별한 관련이없는, 그냥, 유일한 고유 한 값 여기에 스크롤하는 세포를 많이 추가 할 몇 가지 정적 번호를 설정 셀 식별자입니다.이 셀 식별자는 매우 신중하게 생각한 이름을 가지고 있습니다. 여기
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (![self.shownIndexes containsObject:indexPath]) {
[self.shownIndexes addObject:indexPath];
UIView *weeeeCell = [cell contentView];
weeeeCell.layer.transform = self.initialTransform;
weeeeCell.layer.opacity = 0.8;
[UIView animateWithDuration:.65 delay:0.0 usingSpringWithDamping:.85 initialSpringVelocity:.8 options:0 animations:^{
weeeeCell.layer.transform = CATransform3DIdentity;
weeeeCell.layer.opacity = 1;
} completion:^(BOOL finished) {}];
}
}
@end
먼저 우리가 디스플레이에 대해있어 셀이 shownIndexes 목록에 이미있는 경우 우리가 추가되지 않은 경우, 확인, 정말 모두 함께두고 사람의 다음 생성 이 현재 셀 내용보기에 대한 로컬 변수
그런 다음 해당 contentView에 대한 변환을 초기 변환 (ViewDidLoad에서 설정)으로 설정하십시오. 그러면 사용자가 볼 수 있기 전에 셀이 시작 위치로 이동 한 다음 해당 변환을 애니메이션에 다시 적용하여 ID 변환으로 되돌립니다. 나는 거기에도 불투명 함을 가지고있다.
희망이 있습니다.
현재 학교에서 오늘 밤 시도 할 것입니다.) – Erik
매력처럼 작동합니다.이 애니메이션을 변경할 수있는 방법이 있습니까? 대안이 있습니까? 우리는 CATransform3DIdentity를 설정했지만 다른 애니메이션을 생성하는 다른 것으로 변경할 수 있습니까? – Erik
물론이 예제는 유연성 때문에 내가 선택한 경로입니다. 주요 아이디어는 두 단계 과정으로, 애니메이션을 시작하려는 위치에 셀 (또는이 경우에는 셀 내부의 내용보기)을 배치 한 다음 해당 셀을 애니메이션으로 위치에 배치합니다. 이 두 단계는 willDisplayCell 메서드에서 수행됩니다. @ james_womack의 응답은 셀을 움직일 수있는 완벽하게 유효한 방법이기도합니다. 그는 화면에서 전체 셀 프레임을 이동 한 다음 UIView 애니메이션 API를 사용하여 애니메이션 프레임을 움직입니다. – domitall