It is necessary to make a table, when scrolling which will be the effect of the "point of view". An example can be found here - http://mdigital.ee/test/floors/ (Move the mouse right-left). enter image description here

If the example is a multi-storey building, floor and ceiling. There must be a floor number between (indexPath.row).

I'm not good at animation, and I don’t know how to do it, please tell me!

Here is what I could do:

UIView *myView = cell.demoView; CALayer *layer = myView.layer; CATransform3D rotationAndPerspectiveTransform = layer.transform; rotationAndPerspectiveTransform.m34 = 1.0 / -1000; rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform,45.f * M_PI, 1.0, 0.f, 0.0f); [UIView animateWithDuration:.5 animations:^{ layer.transform = rotationAndPerspectiveTransform; }]; 

But the lines rotate synchronously. Any idea how to fix this?

Thank!

  • Css animation? - HELO WORD
  • No, on objective-c. - Vitali Eller
  • besides the floor number, what else do you need to have there? and the number of the floor should be written on the "floor" or between the cells? - Max Mikheyenko
  • the number should be written between the cells, in the future content will be added to the cell, but not the fact that it will be in it, most likely it will be a twist over the table. - Vitali Eller
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

Well, the most difficult thing you have done - 3D transformation. The only thing that remains is to track the scroll and apply the transformation depending on the position of the cell on the screen. For example, this option:

  • UITableView inherited from UIScrollView , so you can get information about the scroll from the scroll view of the delegate and change the transformation based on the position of the cell on the screen.

APDATE

Here's what I got. not very smooth, but I think enough as a starting point. works after the user has started scrolling.

 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { NSArray *cells = [self.table visibleCells]; [cells enumerateObjectsUsingBlock:^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) { // вот вычисление позиции ячейки (/4 добавил для плавности) float position = obj.frame.origin.y/4 + self.table.contentOffset.y; CALayer *layer = obj.layer; //убрираю старый трансформ перед применением нового, чтоб они не складывались layer.transform = CATransform3DIdentity; CATransform3D rotationAndPerspectiveTransform = layer.transform; rotationAndPerspectiveTransform.m34 = 1.0 / -500; //тут можно бесконечно эксперементировать например position/2 и так далее rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, position * M_PI / 180, 1.0, 0.f, 0.0f); layer.transform = rotationAndPerspectiveTransform; }]; 

}

  • I added everything to the method - (void) scrollViewDidScroll: (UIScrollView *) scrollView, but I still could not get the position of the cell on the screen. Let's just say the details of the puzzle are, but not assembled into a single unit. - Vitali Eller
  • UITableView has a visibleCells method visibleCells will return an array of all the cells on the screen. And they already have to ask the frame - Max Mikheyenko
  • Yes, I did it - (void) scrollViewDidScroll:(UIScrollView *)scrollView { for ( FloorCellView* cell in self.tableView.visibleCells) { [self animateCell:cell]; } } - (void) scrollViewDidScroll:(UIScrollView *)scrollView { for ( FloorCellView* cell in self.tableView.visibleCells) { [self animateCell:cell]; } } , but in the animateCell: method animateCell: and the transformation takes place, but there, I can’t finish it yet, the lines rotate in a chaotic direction =) - Vitali Eller
  • you need, as I said, to find out the frame each cell, and apply a transformation based on some formula that includes height - Max Mikheyenko
  • Thanks, trying to come up with a formula, until it came out = ( - Vitali Eller