UITableView倒置
最近在做直播項(xiàng)目,有個(gè)需求就是直播頁(yè)面的文字由下至上滾動(dòng)顯示(不是彈幕),所以就想到將TableView倒置并將數(shù)據(jù)源插入到最前面
倒置實(shí)現(xiàn):
- 將TableView進(jìn)行一個(gè)180°的翻轉(zhuǎn),
- 將Cell進(jìn)行-180°的翻轉(zhuǎn)粥血,
核心代碼
self.tableView.layer.anchorPoint = CGPointMake(0.5, 0.5);
self.tableView.transform = CGAffineTransformMakeRotation(M_PI);
cell.transform = CGAffineTransformMakeRotation(-M_PI);
[self.dataArray insertObject:@"testObj" atIndex:0];
[self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];