无标题文章

一、可翻页的卡片式弹出框的实现

1.首先我们需要自定义绘制一个取消按钮

========

  • 新建一个类QKInfoCardCloseButton继承自UIButton

========

  • 添加属性@property (nonatomic) UIColor *buttonStrokeColor;

=======

  • 实现方法-(instancetype)initWithFrame:(CGRect)frame; -(id)initWithCoder:(NSCoder *)aDecoder -(instancetype)init
-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setUp];
    }
    return self;
}

-(id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setUp];
    }
    return self;
}

-(instancetype)init {
    
    return [self initWithFrame:CGRectZero];
}

=======

  • 设置背景色backgroundColor 设置 self.showsTouchWhenHighlighted = YES;
- (void)setUp {
    
    self.backgroundColor = [UIColor whiteColor];
    
    self.showsTouchWhenHighlighted = YES;
}

=======

  • 重写- (void)drawRect:(CGRect)rect来绘制按钮

2.新建一个类QKInfoCardContainerView继承自UIView用来实现显示区域

  • 添加以下属性

=====

@property (assign, nonatomic) CGFloat cornerRadius;//显示区域的圆角

@property (strong, nonatomic) UIColor *containerBackgroundColor;//显示区域的背景色

@property (strong, nonatomic) UIColor *closeButtonTintColor;//关闭按钮的线条颜色

@property (strong, nonatomic) UIColor *closeButtonBackgroundColor;//关闭按钮的背景色

@property (strong, nonatomic) NSArray *containtViews;//用来展示的子控制器
  • 添加私有属性
@implementation QKInfoCardContainerView {
    QKInfoCardCloseButton *_closeButton;//关闭按钮
    UIView *_containerView;//展示视图
    UIScrollView *_scrollView;
}
  • 同样去实现三个构造方法

===

-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setUp];
    }
    return self;
}

-(id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self setUp];
    }
    return self;
}

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

推荐阅读更多精彩内容

  • ####一、可翻页的卡片式弹出框的实现 1.**首先我们需要自定义绘制一个取消按钮** ======== * 新建...
    15c71b2c9951阅读 203评论 0 1
  • ####一、可翻页的卡片式弹出框的实现 1.**首先我们需要自定义绘制一个取消按钮** ======== * 新建...
    15c71b2c9951阅读 236评论 0 1
  • 【2017年最新】☞ iOS面试题及答案 设计模式是什么? 你知道哪些设计模式,并简要叙述? 设计模式是一种编码经...
    紫色冰雨阅读 624评论 0 1
  • 1、设置UILabel行间距 NSMutableAttributedString*attrString=[[NSM...
    iOS祎阅读 2,241评论 0 0
  • 转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
    40c0490e5268阅读 1,838评论 0 9