美文网首页
UItableView an'n

UItableView an'n

作者: tinghua | 来源:发表于2018-03-19 15:15 被阅读15次

    1.排序的控制是一个UITableViewCellReorderControl,但这是一个私有的类,所以你不能直接访问它。然而,你可以通过子视图的层次结构找到它的图片。

    可以通过UITableViewCell的子类,重写它的 setEditing:animated:方法 如下:

    • (void) setEditing:(BOOL)editing animated:(BOOL)animated
      {
      [super setEditing: editing animated: YES];

      if (editing) {

        for (UIView * view in self.subviews) {
            if ([NSStringFromClass([view class]) rangeOfString: @"Reorder"].location != NSNotFound) {
                for (UIView * subview in view.subviews) {
                    if ([subview isKindOfClass: [UIImageView class]]) {
                        ((UIImageView *)subview).image = [UIImage imageNamed: @"yourimage.png"];
                    }
                }
            }
        }
      

      }
      }

    2.修改UITableViewCell默认的delete按钮的大小

    • (void)willTransitionToState:(UITableViewCellStateMask)state {
      [super willTransitionToState:state];

    if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) {

    for (UIView *subview in self.subviews) {

    if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {

    subview.hidden = YES;
    subview.alpha = 0.0;
    }
    }
    }
    }

    • (void)didTransitionToState:(UITableViewCellStateMask)state {

    [super willTransitionToState:state];

    if (state == UITableViewCellStateShowingDeleteConfirmationMask || state == UITableViewCellStateDefaultMask) {
    for (UIView *subview in self.subviews) {

    if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) {

    UIView *deleteButtonView = (UIView *)[subview.subviews objectAtIndex:0];
    CGRect f = deleteButtonView.frame;
    f.origin.x -= 20;
    deleteButtonView.frame = f; //这里可以改变delete button的大小

    subview.hidden = NO;

    [UIView beginAnimations:@"anim" context:nil];
    subview.alpha = 1.0;
    [UIView commitAnimations];
    }
    }
    }
    }

    相关文章

      网友评论

          本文标题:UItableView an'n

          本文链接:https://www.haomeiwen.com/subject/urlpqftx.html