• 改变滑动删除按钮样式


    在自定义 cell 中实现如下代码:

    // 改变滑动删除按钮样式

    - (void)layoutSubviews {

        [super layoutSubviews];

            for (UIView *subView in self.subviews){

                if([subView isKindOfClass:NSClassFromString(@"UITableViewCellDeleteConfirmationView")]) {

                    CGRect cRect = subView.frame;

                    cRect.origin.y = 10;

                    cRect.size.height = self.contentView.frame.size.height - 20;

                    subView.frame = cRect;

                    

                    // 设置部分圆角(左上与左下)

                    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:subView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(12,12)];

                    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

                    maskLayer.frame = subView.bounds;

                    maskLayer.path = maskPath.CGPath;

                    subView.layer.mask = maskLayer;

                    

                    UIView *confirmView=(UIView *)[subView.subviews firstObject];

                    // 改背景颜色

                    confirmView.backgroundColor=[UIColor redColor];

                    for(UIView *sub in confirmView.subviews){

                        if([sub isKindOfClass:NSClassFromString(@"UIButtonLabel")]){

                            UILabel *deleteLabel=(UILabel *)sub;

                            // 改删除按钮的字体

                            deleteLabel.font=[UIFont boldSystemFontOfSize:15];

                       

                            // 改删除按钮的文字

                            deleteLabel.text=@"删除";

                            }

                        }

                    

                    break;

                }

            }

        

    }

  • 相关阅读:
    装饰器模式(学习笔记10)
    软件设计七大原则 (学习笔记2)
    设计模式(学习笔记1)
    桥接模式 (学习笔记9)
    Mini2440裸机开发之LCD基础
    配置中心java客户端实现
    高效CSS写法
    整理电脑里面的前端开发中的小Tips【及时更新】
    IE6 position:fixed (固定定位)的解决方案
    jquery 文档操作
  • 原文地址:https://www.cnblogs.com/zhufengshibei/p/7474477.html
Copyright © 2020-2023  润新知