Swipable实现了类似于网易新闻的标签选择页,只需几行代码即可集成,具体使用方法请参考Demo。
Swipable是利用TableView来实现的,每个cell对应着一个ViewController的view(如下所示);然后利用旋转实现。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:kHorizonalCellID forIndexPath:indexPath];
cell.contentView.transform = CGAffineTransformMakeRotation(M_PI_2);
cell.contentView.backgroundColor = [UIColor colorWithRed:235.0/255 green:235.0/255 blue:243.0/255 alpha:1.0];
cell.selectionStyle = UITableViewCellSeparatorStyleNone;
UIViewController *controller = _controllers[indexPath.row];
controller.view.frame = cell.contentView.bounds;
[cell.contentView addSubview:controller.view];
return cell;
}
当没有旋转时:
TableView进行旋转90度:
TableView中的每个cell旋转90度:
至此,Swipable便实现了。
@开源中国:这个框架是在开源中国iOS客户端
中总结出来的,并在此基础上进行了完善,欢迎大家再次进行完善。开源中国iOS客户端
源代码地址:http://git.oschina.net/oschina/iphone-app
。