MGSwipeTableCell

MGSwipeTableCell是一個UITableViewCell子類, git

它實現了左,右滑動展開更多按鈕用來實現一些相關操做就和QQ好友列表滑動展開的按鈕同樣,封裝的很好,動畫效果也處理很到位,廢話很少說,咱們來看下它的簡單集成 github

1.寫一個類來繼承他,和UITableView同樣的使用 編程

2.設置代理delegate而且實現協議MGSwipeTableCellDelegate的一些方法 數組

  1 #pragma mark - MGSwipeTableCellDelegate app

複製代碼
 2 
 3 - (NSArray *)swipeTableCell:(MGSwipeTableCell *)cell swipeButtonsForDirection:(MGSwipeDirection)direction swipeSettings:(MGSwipeSettings *)swipeSettings expansionSettings:(MGSwipeExpansionSettings *)expansionSettings {
 4      // 左邊
 5      expansionSettings.fillOnTrigger = YES;
 6      if (direction == MGSwipeDirectionLeftToRight) {
 7 
 8          // 返回的數組必須是button類型的
 9           return @[[MGSwipeButton buttonWithTitle: @" 哈哈 " icon:nil backgroundColor:[UIColor redColor] padding: 15 callback:^BOOL(MGSwipeTableCell * sender){
10             NSLog( @" Convenience callback received (left). ");
11              return YES;
12         }],[MGSwipeButton buttonWithTitle: @" 哈哈 " icon:nil backgroundColor:[UIColor redColor] padding: 15 callback:^BOOL(MGSwipeTableCell * sender){
13             NSLog( @" Convenience callback received (left). ");
14              return YES;
15         }]];
16     }
17      // 右邊
18       else {
19         UIButton *view = [[UIButton alloc]initWithFrame:CGRectMake( 003030)];
20         view.userInteractionEnabled = YES;
21         view.backgroundColor = [UIColor yellowColor];
22          return @[view];
23     }
24 }
25 
26 
27 - (BOOL)swipeTableCell:(MGSwipeTableCell *)cell tappedButtonAtIndex:(NSInteger)index direction:(MGSwipeDirection)direction fromExpansion:(BOOL)fromExpansion {
28     NSLog( @" %ld:%ld  ",index,direction);
29      return YES;
30 }
複製代碼

 

3.能夠運行查看效果了 測試

github連接:https://github.com/MortimerGoro/MGSwipeTableCell  動畫

 


MGSwipeTableCell是UITableViewCell的子類,用多種過渡方式展現可點擊的按鈕,該庫兼容全部不一樣的方式來建立UITableViewCell:系統預置的類型、以編程方式建立cell......

測試環境:Xcode 5.0,iOS 6.0以上

轉換demo
Border transition

 
Clip transition

 
3D transition

 
Static transition

 
Drag transition

 
相關文章
相關標籤/搜索