UItableView an'n

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];
}
}
}
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容